classification
Title: math.tan has poor accuracy near pi/2 on OS X Tiger
Type: behavior Stage: resolved
Components: Extension Modules, macOS Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: mark.dickinson Nosy List: mark.dickinson, ned.deily, python-dev, ronaldoussoren
Priority: normal Keywords:

Created on 2016-09-04 08:35 by mark.dickinson, last changed 2016-09-05 18:01 by mark.dickinson. This issue is now closed.

Messages (7)
msg274350 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2016-09-04 08:35
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.
msg274352 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-04 08:59
New changeset b4d52df5595e by Mark Dickinson in branch 'default':
Issue #27953: skip failing math and cmath tests for tan on OS X 10.4.
https://hg.python.org/cpython/rev/b4d52df5595e
msg274353 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2016-09-04 10:24
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).
msg274395 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-09-05 07:59
It would be nice to use the existing @requires_mac_ver() decorator to skip the tests (see Lib/test/support/__init__.py).
msg274406 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2016-09-05 16:41
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.
msg274409 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-09-05 17:40
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.
msg274413 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2016-09-05 18:01
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.
History
Date User Action Args
2016-09-05 18:01:13mark.dickinsonsetmessages: + msg274413
2016-09-05 17:40:58ned.deilysetmessages: + msg274409
2016-09-05 16:41:02mark.dickinsonsetmessages: + msg274406
2016-09-05 07:59:21ned.deilysetmessages: + msg274395
2016-09-04 11:51:29mark.dickinsonsettitle: tan has poor accuracy near pi/2 on OS X Tiger -> math.tan has poor accuracy near pi/2 on OS X Tiger
2016-09-04 10:24:35mark.dickinsonsetstatus: open -> closed
resolution: wont fix
messages: + msg274353

stage: resolved
2016-09-04 08:59:04python-devsetnosy: + python-dev
messages: + msg274352
2016-09-04 08:35:39mark.dickinsoncreate