[issue15477] test_cmath failures on OS X 10.8
Mark Dickinson added the comment: Perfect. Thanks, Ned! I'll update the Apple issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Mark Dickinson added the comment: Update: I just received this from Apple, for bug #12128251. We believe this issue has been addressed in OS X Mavericks GM build 13A603. Please verify with this release, and update this report with your results. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Ned Deily added the comment: I built Python at 3fba718e46e5 on both 10.8 and 10.9 which was just before your changes for this issue went in, Mark. On 10.8: test_cmath fails and: math.log1p(-0.0) 0.0 And, indeed, on 10.9, it passes and: math.log1p(-0.0) -0.0 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Changes by alef alessandro.for...@eumetsat.int: -- nosy: +alef ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Changes by alef alessandro.for...@eumetsat.int: -- nosy: -alef ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Changes by Mark Dickinson dicki...@gmail.com: -- assignee: - mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Mark Dickinson added the comment: Trent, many thanks for the report and analysis. The LOG1P_DROPS_ZERO_SIGN hackery was a result of a previous attempt to 'fix' the tests on another platform whose log1p didn't preserve zero signs. But now that this behaviour has emerged on OS X too, I think it might be time to fix this in the Python core code (i.e., add a workaround for the buggy OS behaviour) instead of trying to make the tests pass again. Attached is a patch that adds a workaround for this on all platforms that have a system log1p. I was originally thinking of adding this workaround only on OS X (so as not to unnecessarily punish those platforms that get it right), but after running some timings (see below) it seems that the workaround is insignificant performance-wise, so we might as well keep things simple and add it on all platforms. Trent, if you have time, please could you try this patch on OS X 10.8 and see if it fixes all the test_cmath and test_math failures? Some timings on OS X 10.6. Current default branch (pass value directly onto system log1p): iwasawa:cpython mdickinson$ ./python.exe -m timeit -s 'from math import log1p; x = 2.3' 'log1p(x)' 1000 loops, best of 3: 0.0685 usec per loop With the attached patch (do zero check, then pass value directly onto system log1p): iwasawa:cpython mdickinson$ ./python.exe -m timeit -s 'from math import log1p; x = 2.3' 'log1p(x)' 1000 loops, best of 3: 0.0686 usec per loop -- Added file: http://bugs.python.org/file26884/log1p_sign_workaround.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Mark Dickinson added the comment: Updated patch that also removes the sysconfig checks from the cmath tests. -- Added file: http://bugs.python.org/file26885/log1p_sign_workaround.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Changes by Mark Dickinson dicki...@gmail.com: Removed file: http://bugs.python.org/file26884/log1p_sign_workaround.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Changes by Mark Dickinson dicki...@gmail.com: -- components: +Extension Modules stage: - patch review type: - behavior versions: +Python 2.7, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Mark Dickinson added the comment: See also http://bugs.python.org/issue9920; the patch here *should* fix that issue, too. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Trent Nelson added the comment: Happy to report your patch does the trick Mark. test_cmath passes on 10.7 and 10.8 with it applied. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Martin v. Löwis added the comment: BTW, did anybody file a bug report with Apple? Even to my untrained eye, that looks like a clear violation of the POSIX standard: If x is ±0, or +Inf, x shall be returned. http://pubs.opengroup.org/onlinepubs/009604599/functions/log1p.html C seems to make it implementation-defined, unless the implementation defines __STDC_IEC_559__, in which case log1p also needs to return ±0 (C99 F.9.3.9, C11 F.10.3.9). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Mark Dickinson added the comment: BTW, did anybody file a bug report with Apple? I'll file one. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Roundup Robot added the comment: New changeset 08418369da7b by Mark Dickinson in branch '3.2': Issue #15477: Add workaround for log1p(-0.0) on platforms where it's broken. http://hg.python.org/cpython/rev/08418369da7b -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Roundup Robot added the comment: New changeset 336653319112 by Mark Dickinson in branch 'default': Issue #15477: Merge fix from 3.2 http://hg.python.org/cpython/rev/336653319112 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Mark Dickinson added the comment: Apple bug report filed: Bug ID# 12128251. Closing the issue. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Martin v. Löwis added the comment: Without looking into the details of the issue: conditionalizing a work-around on OSX sounds right. On the one hand, it may penalize OSX releases which get it right. OTOH, it's all Apple's fault (IIUC), so they deserve it :-) Further, using a build-time check for the OS release is inappropriate, since the binary should work on other releases as well; a run-time check is probably more costly than the work-around. -- nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Trent Nelson added the comment: I ran into this last night and posted to python-dev before realizing this bug had been raised: http://mail.python.org/pipermail/python-dev/2012-August/121359.html I'll reproduce it here as I made a few observations that haven't yet been mentioned in this issue: The Mountain Lion build slave I set up earlier this evening fails on test_cmath: == FAIL: test_specific_values (test.test_cmath.CMathTests) -- Traceback (most recent call last): File /Volumes/bay2/buildslave/cpython/2.7.snakebite-mountainlion-amd64/build/Lib/test/test_cmath.py, line 352, in test_specific_values msg=error_message) File /Volumes/bay2/buildslave/cpython/2.7.snakebite-mountainlion-amd64/build/Lib/test/test_cmath.py, line 94, in rAssertAlmostEqual 'got {!r}'.format(a, b)) AssertionError: atan: atan(complex(0.0, 0.0)) Expected: complex(0.0, 0.0) Received: complex(0.0, -0.0) Received value insufficiently close to expected value. Mountain Lion's atan/log1p appear to drop the negative sign when passed in -0.0, whereas previous versions of OS X didn't: Mountain Lion: % ~/log1p-viper log1p_drops_zero_sign_test: atan2(log1p(-0.), -1.) != atan2(-0., -1.) 3.14159 vs -3.14159 atan_drops_zero_sign_test: atan2(-0., 0.): -0.0 atan2( 0., -0.): 3.14159 atan2(-0., -0.): -3.14159 atan2( 0., 0.): 0.0 log1p(-0.): 0.0 log1p( 0.): 0.0 Lion: % ./log1p log1p_drops_zero_sign_test: atan2(log1p(-0.), -1.) == atan2(-0., -1.) -3.14159 vs -3.14159 atan_drops_zero_sign_test: atan2(-0., 0.): -0.0 atan2( 0., -0.): 3.14159 atan2(-0., -0.): -3.14159 atan2( 0., 0.): 0.0 log1p(-0.): -0.0 log1p( 0.): 0.0 (The C code for that is below.) configure.ac already has a test for this (it makes mention of AIX having similar behaviour), and the corresponding sysconfig entry named 'LOG1P_DROPS_ZERO_SIGN' is already being used on a few tests, i.e.: # The algorithm used for atan and atanh makes use of the system # log1p function; If that system function doesn't respect the sign # of zero, then atan and atanh will also have difficulties with # the sign of complex zeros. @requires_IEEE_754 @unittest.skipIf(sysconfig.get_config_var('LOG1P_DROPS_ZERO_SIGN'), system log1p() function doesn't preserve the sign) def testAtanSign(self): for z in complex_zeros: self.assertComplexIdentical(cmath.atan(z), z) @requires_IEEE_754 @unittest.skipIf(sysconfig.get_config_var('LOG1P_DROPS_ZERO_SIGN'), system log1p() function doesn't preserve the sign) def testAtanhSign(self): for z in complex_zeros: self.assertComplexIdentical(cmath.atanh(z), z) Taking a look at cmath_testcases.txt, and we can see this: -- These are tested in testAtanSign in test_cmath.py -- atan atan 0.0 0.0 - 0.0 0.0 -- atan0001 atan 0.0 -0.0 - 0.0 -0.0 -- atan0002 atan -0.0 0.0 - -0.0 0.0 -- atan0003 atan -0.0 -0.0 - -0.0 -0.0 However, a few lines down, those tests crop up again: -- special values atan1000 atan -0.0 0.0 - -0.0 0.0 snip atan1014 atan 0.0 0.0 - 0.0 0.0 which is what causes the current test failures. I hacked test_cmath.py a bit to spit out all the errors it finds after it's finished parsing the test file (instead of bombing out on the first one), and it yielded this: FAIL: test_specific_values (test.test_cmath.CMathTests) -- Traceback (most recent call last): File /Volumes/bay2/buildslave/cpython/3.2.snakebite-mountainlion-amd64/build/Lib/test/test_cmath.py, line 446, in test_specific_values self.fail(\n.join(failures)) AssertionError: atan1000: atan(complex(-0.0, 0.0)) Expected: complex(-0.0, 0.0) Received: complex(-0.0, -0.0) Received value insufficiently close to expected value. atan1014: atan(complex(0.0, 0.0)) Expected: complex(0.0, 0.0) Received: complex(0.0, -0.0) Received value insufficiently close to expected value. atanh0225: atanh(complex(-0.0, 5.6067e-320)) Expected: complex(-0.0, 5.6067e-320)
[issue15477] test_cmath failures on OS X 10.8
Mark Dickinson added the comment: These types of run-time tests based on configure-time tests are problematic for binary installations of Python, like the OS X installers. Understood. I'm wondering how to fix this for Python, given that we're unlikely to see an OS-level fix for a while. There's an easy workaround, namely to add an if (x == 0.0) return x; before any use of the system log1p; the issue is how and when to apply this workaround. One option is always to apply the workaround, but this feels to me as though it's unnecessarily penalising those OSs that get it right; maybe just always apply the workaround on OS X? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
New submission from Ned Deily n...@acm.org: == FAIL: testAtanSign (test.test_cmath.CMathTests) -- Traceback (most recent call last): File /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/test/test_cmath.py, line 526, in testAtanSign self.assertComplexIdentical(cmath.atan(z), z) File /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/test/test_cmath.py, line 96, in assertComplexIdentical self.assertFloatIdentical(x.imag, y.imag) File /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/test/test_cmath.py, line 86, in assertFloatIdentical self.fail(msg.format(x, y)) AssertionError: floats -0.0 and 0.0 are not identical: zeros have different signs == FAIL: testAtanhSign (test.test_cmath.CMathTests) -- Traceback (most recent call last): File /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/test/test_cmath.py, line 533, in testAtanhSign self.assertComplexIdentical(cmath.atanh(z), z) File /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/test/test_cmath.py, line 95, in assertComplexIdentical self.assertFloatIdentical(x.real, y.real) File /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/test/test_cmath.py, line 86, in assertFloatIdentical self.fail(msg.format(x, y)) AssertionError: floats 0.0 and -0.0 are not identical: zeros have different signs == FAIL: test_specific_values (test.test_cmath.CMathTests) -- Traceback (most recent call last): File /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/test/test_cmath.py, line 382, in test_specific_values msg=error_message) File /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/test/test_cmath.py, line 128, in rAssertAlmostEqual 'got {!r}'.format(a, b)) AssertionError: atan1000: atan(complex(-0.0, 0.0)) Expected: complex(-0.0, 0.0) Received: complex(-0.0, -0.0) Received value insufficiently close to expected value. -- Failures seen across various compilers and deployment targets and running the tests with the same binaries on earlier OS X versions do not fail. FWIW, the Apple-supplied Python 2.7.2 in 10.8 (that's the most recent version supplied) also has a test_cmath failure: == FAIL: test_specific_values (test.test_cmath.CMathTests) -- Traceback (most recent call last): File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/test/test_cmath.py, line 352, in test_specific_values msg=error_message) File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/test/test_cmath.py, line 94, in rAssertAlmostEqual 'got {!r}'.format(a, b)) AssertionError: atan: atan(complex(0.0, 0.0)) Expected: complex(0.0, 0.0) Received: complex(0.0, -0.0) Received value insufficiently close to expected value. -- Is there any reason to not consider this a platform bug? If it is, what should the bug report be? -- messages: 166642 nosy: mark.dickinson, ned.deily priority: normal severity: normal status: open title: test_cmath failures on OS X 10.8 versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Mark Dickinson dicki...@gmail.com added the comment: Judging by previous reports of this type, it's probably either a bug in the platform math library or a compiler optimization bug (or possibly a combination of the two: one previous OS X bug involved calls to sin / cos being 'optimized' to a badly implemented single call to cexp). I assume the failure still happens in debug mode? If so, a math library bug seems more likely. Are there any math module failures? It's not immediately obvious what the bug is, since the cmath module functions are not just simple wrappers around library functions. In this case it looks like either atan2 or log1p is doing the wrong thing with signs of zeros. What do math.log1p(0.0) and math.log1p(-0.0) give? (Answers *should* be 0.0 and -0.0 respectively.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Mark Dickinson dicki...@gmail.com added the comment: Also: what's HAVE_LOG1P for this build? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Ned Deily added the comment: I assume the failure still happens in debug mode? Yes Are there any math module failures? No What do math.log1p(0.0) and math.log1p(-0.0) give? (Answers *should* be 0.0 and -0.0 respectively.) math.log1p(0.0) 0.0 math.log1p(-0.0) 0.0 sysconfig.get_config_var('HAVE_LOG1P') 1 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Mark Dickinson added the comment: math.log1p(0.0) 0.0 math.log1p(-0.0) 0.0 Ah, that would do it, then. It looks as though the system's log1p function is buggy, in the sense that it doesn't follow C99 Annex F (F.9.3.9). It also doesn't agree with what 'man log1p' says on my OS X 10.6 Macbook: under 'SPECIAL VALUES', it says: 'log1p(+-0) returns +-0.' I'm puzzled about one thing, though: there's a test for this problem in the configure script, and LOG1P_DROPS_ZERO_SIGN should be defined in this case---in that case, the two testAtanSign and testAtanhSign tests are skipped. So it looks as though LOG1P_DROPS_ZERO_SIGN isn't being defined on this machine; I'm not sure why---there may be a compiler optimization kicking in in the configure test. (Is this clang or gcc, BTW?) So definitely worth a bug report, I'd say, though perhaps it's too much to hope for a fix within the lifetime of 10.8. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15477] test_cmath failures on OS X 10.8
Ned Deily added the comment: It also doesn't agree with what 'man log1p' says on my OS X 10.6 Macbook: under 'SPECIAL VALUES', it says: 'log1p(+-0) returns +-0.' That manpage is unchanged for 10.8. I'm puzzled about one thing, though: there's a test for this problem in the configure script, and LOG1P_DROPS_ZERO_SIGN should be defined in this case---in that case, the two testAtanSign and testAtanhSign tests are skipped. So it looks as though LOG1P_DROPS_ZERO_SIGN isn't being defined on this machine; I'm not sure why---there may be a compiler optimization kicking in in the configure test. Ah, this rings a bell and points out yet another issue: 1. The configure test is working properly: when run on 10.8, LOG1P_DROPS_ZERO_SIGN is set to 1. However, something I just ran into recently, the unittest skip idiom using sysconfig.get_config_vars results - as is being used here in test_cmath - doesn't seem to work properly. I see it is used in test_math and test_subprocess as well. I'll look into that. 2. These types of run-time tests based on configure-time tests are problematic for binary installations of Python, like the OS X installers. For example, the OS X installers are built on earlier versions of OS X where a configuration test (like this one) may have one result but not necessarily the same result on all supported target configurations where the binary Pythons may be installed. And, in general, multiple-architecture builds, in particular, OS X universal builds may have different configuration values per architecture embedded in one executable (i386 vs x86_64 or i386 vs ppc or i386 vs x86_64 vs ppc) that are not reflected in the single architecture ./configure results. I guess it's time to open an issue on that can of worms. (Is this clang or gcc, BTW?) It's clang which is now the only supported option with Xcode 4.4 on either 10.7 or 10.8. More importantly, 10.8 is the first OS X release which itself was built with clang; 10.7 was built with the transitional llvm-gcc compiler. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com