gh-155966: Correct handling of tanpi(0.5) (#155966) - #155980
Conversation
As pointed out in the issue, the exceptional half-integer (0.5, 1.5, etc) inputs of tanpi were not handled properly. Now, these raise ValueError and this is tested by `test.test_math` through its list of test cases.
| tanpi30115 tanpi 1.5 -> inf invalid | ||
| tanpi30118 tanpi -1.5 -> inf invalid |
There was a problem hiding this comment.
Standard says: tanpi(n + 1/2) returns -oo and raises the "divide-by-zero" floating-point exception, for odd integers n.
There was a problem hiding this comment.
My reference (draft ISO/IEC 9899:2023 F.10.1.14) has this:
— tanpi(n + 1/2 ) returns +∞ and raises the “divide-by-zero” floating-point exception, for even integers n.
— tanpi(n + 1/2 ) returns +∞ and raises the “divide-by-zero” floating-point exception, for odd integers n.
I don't think the test harness can actually verify the return value of the underlying C API since it was consumed when the exception is generated. In a standalone C program I verified that the signs of infinity for the m_atanpi implementation I provided match the GNU C library implementation. (In fact you can even write something like -> 7 invalid for these exception cases and the test harness gives a pass)
I can still correct the signs of infinity shown here, is that what you're requesting?
There was a problem hiding this comment.
I don't think the test harness can actually verify the return value of the underlying C API since it was consumed when the exception is generated.
Yes, though it's better to match the standard. Maybe in future we can have access to such values, see e.g. #133895.
| atan2pi22003 atan2pi inf 1 -> 0.5 | ||
| atan2pi22004 atan2pi -inf 1 -> -0.5 | ||
| atan2pi22005 atan2pi nan 1 -> nan |
There was a problem hiding this comment.
Those ids not clash with other. Lets revert such changes.
Keep only:
AssertionError: Failures in test_mtestfile:
Duplicate test id atan2pi20000
Duplicate test id atan2pi20001
Duplicate test id atan2pi20002
Duplicate test id atan2pi30000
Duplicate test id atan2pi30001
Duplicate test id atan2pi30002
…YOADY.rst Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
As pointed out in #155966, the exceptional half-integer (0.5, 1.5, etc) inputs of tanpi were not handled properly.
Now, these raise ValueError and this is tested by
test.test_maththrough its list of test cases.In the process of working on this, I noticed that I had incorrectly added duplicate test ids and that this was not treated as an error by the test harness. I have corrected this and made it part of the test.
math.tanpiis untested at its poles and no test-file flag fits #155966