mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-41513: Improve speed and accuracy of math.hypot() (GH-21803)
This commit is contained in:
parent
39dab24621
commit
fff3c28052
3 changed files with 44 additions and 6 deletions
|
@ -795,7 +795,8 @@ class MathTests(unittest.TestCase):
|
|||
# Verify scaling for extremely large values
|
||||
fourthmax = FLOAT_MAX / 4.0
|
||||
for n in range(32):
|
||||
self.assertEqual(hypot(*([fourthmax]*n)), fourthmax * math.sqrt(n))
|
||||
self.assertTrue(math.isclose(hypot(*([fourthmax]*n)),
|
||||
fourthmax * math.sqrt(n)))
|
||||
|
||||
# Verify scaling for extremely small values
|
||||
for exp in range(32):
|
||||
|
@ -904,8 +905,8 @@ class MathTests(unittest.TestCase):
|
|||
for n in range(32):
|
||||
p = (fourthmax,) * n
|
||||
q = (0.0,) * n
|
||||
self.assertEqual(dist(p, q), fourthmax * math.sqrt(n))
|
||||
self.assertEqual(dist(q, p), fourthmax * math.sqrt(n))
|
||||
self.assertTrue(math.isclose(dist(p, q), fourthmax * math.sqrt(n)))
|
||||
self.assertTrue(math.isclose(dist(q, p), fourthmax * math.sqrt(n)))
|
||||
|
||||
# Verify scaling for extremely small values
|
||||
for exp in range(32):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue