pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/28aea5d07d163105b42acd81c1651397ef95ea57

5097560d244c08.css" /> gh-123836: Check zero signs in math_testcases.txt (#123854) · python/cpython@28aea5d · GitHub
Skip to content

Commit 28aea5d

Browse files
authored
gh-123836: Check zero signs in math_testcases.txt (#123854)
Just like cmath_testcases.txt. These tests require IEEE 754 anyway. Correct zero sign for sqrt tests to match math.h convention.
1 parent 14e5bdc commit 28aea5d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Lib/test/test_math.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ def result_check(expected, got, ulp_tol=5, abs_tol=0.0):
187187

188188
# Check exactly equal (applies also to strings representing exceptions)
189189
if got == expected:
190+
if not got and not expected:
191+
if math.copysign(1, got) != math.copysign(1, expected):
192+
return f"expected {expected}, got {got} (zero has wrong sign)"
190193
return None
191194

192195
failure = "not equal"
@@ -2067,6 +2070,13 @@ def test_testfile(self):
20672070
except OverflowError:
20682071
result = 'OverflowError'
20692072

2073+
# C99+ says for math.h's sqrt: If the argument is +∞ or ±0, it is
2074+
# returned, unmodified. On another hand, for csqrt: If z is ±0+0i,
2075+
# the result is +0+0i. Lets correct zero sign of er to follow
2076+
# first convention.
2077+
if id in ['sqrt0002', 'sqrt0003', 'sqrt1001', 'sqrt1023']:
2078+
er = math.copysign(er, ar)
2079+
20702080
# Default tolerances
20712081
ulp_tol, abs_tol = 5, 0.0
20722082

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy