Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math.tan has poor accuracy near pi/2 on OS X Tiger #72140

Closed
mdickinson opened this issue Sep 4, 2016 · 7 comments
Closed

math.tan has poor accuracy near pi/2 on OS X Tiger #72140

mdickinson opened this issue Sep 4, 2016 · 7 comments
Assignees
Labels
extension-modules C modules in the Modules dir OS-mac type-bug An unexpected behavior, bug, or error

Comments

@mdickinson
Copy link
Member

BPO 27953
Nosy @ronaldoussoren, @mdickinson, @ned-deily

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/mdickinson'
closed_at = <Date 2016-09-04.10:24:35.287>
created_at = <Date 2016-09-04.08:35:39.552>
labels = ['extension-modules', 'OS-mac', 'type-bug']
title = 'math.tan has poor accuracy near pi/2 on OS X Tiger'
updated_at = <Date 2016-09-05.18:01:13.201>
user = 'https://github.com/mdickinson'

bugs.python.org fields:

activity = <Date 2016-09-05.18:01:13.201>
actor = 'mark.dickinson'
assignee = 'mark.dickinson'
closed = True
closed_date = <Date 2016-09-04.10:24:35.287>
closer = 'mark.dickinson'
components = ['Extension Modules', 'macOS']
creation = <Date 2016-09-04.08:35:39.552>
creator = 'mark.dickinson'
dependencies = []
files = []
hgrepos = []
issue_num = 27953
keywords = []
message_count = 7.0
messages = ['274350', '274352', '274353', '274395', '274406', '274409', '274413']
nosy_count = 4.0
nosy_names = ['ronaldoussoren', 'mark.dickinson', 'ned.deily', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue27953'
versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']

@mdickinson
Copy link
Member Author

Opening this for the record; I intend to close as "wont fix".

The tan function has poor accuracy for inputs near pi/2 on OS X 10.4. This is a direct consequence of a poor libm implementation, so there's little we can do about it short of re-implenting tan ourselves. 10.4 is ancient enough by now that it's difficult to care too much.

Example failures:

======================================================================
FAIL: test_testfile (test.test_math.MathTests)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/test/test_math.py", line 1190, in test_testfile
    '\n  '.join(failures))
AssertionError: Failures in test_testfile:
  tan0064: tan(1.5707963267948961): expected 1978937966095219.0, got 1978945885716843.0 (error = 7.92e+09 (31678486496 ulps); permitted error = 0 or 5 ulps)

and a corresponding failure in cmath:

======================================================================
FAIL: test_specific_values (test.test_cmath.CMathTests)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/test/test_cmath.py", line 398, in test_specific_values
    msg=error_message)
  File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/test/test_cmath.py", line 147, in rAssertAlmostEqual
    '{!r} and {!r} are not sufficiently close'.format(a, b))
AssertionError: tan0064: tan(complex(1.5707963267948961, 0.0))
Expected: complex(1978937966095219.0, 0.0)
Received: complex(1978945885716843.0, 0.0)
Received value insufficiently close to expected value.

@mdickinson mdickinson self-assigned this Sep 4, 2016
@mdickinson mdickinson added extension-modules C modules in the Modules dir OS-mac type-bug An unexpected behavior, bug, or error labels Sep 4, 2016
@python-dev
Copy link
Mannequin

python-dev mannequin commented Sep 4, 2016

New changeset b4d52df5595e by Mark Dickinson in branch 'default':
Issue bpo-27953: skip failing math and cmath tests for tan on OS X 10.4.
https://hg.python.org/cpython/rev/b4d52df5595e

@mdickinson
Copy link
Member Author

The relevant tests are now skipped on OS X < 10.5, and test_math and test_cmath are passing on the OS X Tiger buildbot. Closing (as "wont fix", since we haven't actually fixed the underlying issue).

@mdickinson mdickinson changed the title tan has poor accuracy near pi/2 on OS X Tiger math.tan has poor accuracy near pi/2 on OS X Tiger Sep 4, 2016
@ned-deily
Copy link
Member

It would be nice to use the existing @requires_mac_ver() decorator to skip the tests (see Lib/test/support/init.py).

@mdickinson
Copy link
Member Author

Ned: that's for skipping an entire test method, right? Here a single test method tests a few hundred different special cases; we want to exclude only one of those cases.

@ned-deily
Copy link
Member

Mark, ah, yes, that's true. So the tests would have to be separated out into a separate test case method. So, not worth the effort.

@mdickinson
Copy link
Member Author

Given enough time, it would make a lot of sense to adapt these tests to use the subtests machinery (though it's not immediately clear to me how to make @requires_mac_ver work with the subtests machinery). I'm afraid this issue was a bit of a quick fix to get the buildbots back to working state.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir OS-mac type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants