Skip to content

Commit 8594452

Browse files
committed
Add tests for math.atan2() and update NEWS
1 parent 6a48f02 commit 8594452

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎Lib/test/test_math.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,15 @@ def testAtan2(self):
348348
self.assertTrue(math.isnan(math.atan2(NAN, 2.3)))
349349
self.assertTrue(math.isnan(math.atan2(NAN, INF)))
350350
self.assertTrue(math.isnan(math.atan2(NAN, NAN)))
351+
# overflow and underflow of y/x
352+
self.assertEqual(math.atan2(1E-320, 1E300), 0.0)
353+
self.assertEqual(math.atan2(-1E-320, 1E300), -0.0)
354+
self.assertAlmostEqual(math.atan2(1E300, 1E-320), math.pi/2)
355+
self.assertAlmostEqual(math.atan2(1E300, -1E-320), math.pi/2)
356+
self.assertAlmostEqual(math.atan2(1E-320, -1E300), math.pi)
357+
self.assertAlmostEqual(math.atan2(-1E-320, -1E300), -math.pi)
358+
self.assertAlmostEqual(math.atan2(-1E300, 1E-320), -math.pi/2)
359+
self.assertAlmostEqual(math.atan2(-1E300, -1E-320), -math.pi/2)
351360

352361
def testCbrt(self):
353362
self.assertRaises(TypeError, math.cbrt)
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
The function :func:`cmath.phase` should not raise ``OverflowError``, and the
2-
functions :func:`math.atan2`, :func:`math.atan2pi`, and :func:`cmath.phase`
3-
should not raise ``ValueError``. Contributed by High Performance Kernels LLC.
1+
:func:`math.atan2` and :func:`math.atan2pi` no longer raise :exc:`ValueError`.
2+
:func:`cmath.phase` no longer raises :exc:`OverflowError` or :exc:`ValueError`,
3+
and the values of ``math.atan2(b, a)`` and ``cmath.phase(complex(a, b))`` always
4+
match. Contributed by High Performance Kernels LLC.

0 commit comments

Comments
 (0)