(self)
| 2616 | self.assertIsNaN(math.fma(a, b, math.nan)) |
| 2617 | |
| 2618 | def test_fma_infinities(self): |
| 2619 | # Cases involving infinite inputs or results. |
| 2620 | positives = [1e-300, 2.3, 1e300, math.inf] |
| 2621 | finites = [-1e300, -2.3, -1e-300, -0.0, 0.0, 1e-300, 2.3, 1e300] |
| 2622 | non_nans = [-math.inf, -2.3, -0.0, 0.0, 2.3, math.inf] |
| 2623 | |
| 2624 | # ValueError due to inf * 0 computation. |
| 2625 | for c in non_nans: |
| 2626 | for infinity in [math.inf, -math.inf]: |
| 2627 | for zero in [0.0, -0.0]: |
| 2628 | with self.subTest(c=c, infinity=infinity, zero=zero): |
| 2629 | with self.assertRaises(ValueError): |
| 2630 | math.fma(infinity, zero, c) |
| 2631 | with self.assertRaises(ValueError): |
| 2632 | math.fma(zero, infinity, c) |
| 2633 | |
| 2634 | # ValueError when a*b and c both infinite of opposite signs. |
| 2635 | for b in positives: |
| 2636 | with self.subTest(b=b): |
| 2637 | with self.assertRaises(ValueError): |
| 2638 | math.fma(math.inf, b, -math.inf) |
| 2639 | with self.assertRaises(ValueError): |
| 2640 | math.fma(math.inf, -b, math.inf) |
| 2641 | with self.assertRaises(ValueError): |
| 2642 | math.fma(-math.inf, -b, -math.inf) |
| 2643 | with self.assertRaises(ValueError): |
| 2644 | math.fma(-math.inf, b, math.inf) |
| 2645 | with self.assertRaises(ValueError): |
| 2646 | math.fma(b, math.inf, -math.inf) |
| 2647 | with self.assertRaises(ValueError): |
| 2648 | math.fma(-b, math.inf, math.inf) |
| 2649 | with self.assertRaises(ValueError): |
| 2650 | math.fma(-b, -math.inf, -math.inf) |
| 2651 | with self.assertRaises(ValueError): |
| 2652 | math.fma(b, -math.inf, math.inf) |
| 2653 | |
| 2654 | # Infinite result when a*b and c both infinite of the same sign. |
| 2655 | for b in positives: |
| 2656 | with self.subTest(b=b): |
| 2657 | self.assertEqual(math.fma(math.inf, b, math.inf), math.inf) |
| 2658 | self.assertEqual(math.fma(math.inf, -b, -math.inf), -math.inf) |
| 2659 | self.assertEqual(math.fma(-math.inf, -b, math.inf), math.inf) |
| 2660 | self.assertEqual(math.fma(-math.inf, b, -math.inf), -math.inf) |
| 2661 | self.assertEqual(math.fma(b, math.inf, math.inf), math.inf) |
| 2662 | self.assertEqual(math.fma(-b, math.inf, -math.inf), -math.inf) |
| 2663 | self.assertEqual(math.fma(-b, -math.inf, math.inf), math.inf) |
| 2664 | self.assertEqual(math.fma(b, -math.inf, -math.inf), -math.inf) |
| 2665 | |
| 2666 | # Infinite result when a*b finite, c infinite. |
| 2667 | for a, b in itertools.product(finites, finites): |
| 2668 | with self.subTest(b=b): |
| 2669 | self.assertEqual(math.fma(a, b, math.inf), math.inf) |
| 2670 | self.assertEqual(math.fma(a, b, -math.inf), -math.inf) |
| 2671 | |
| 2672 | # Infinite result when a*b infinite, c finite. |
| 2673 | for b, c in itertools.product(positives, finites): |
| 2674 | with self.subTest(b=b, c=c): |
| 2675 | self.assertEqual(math.fma(math.inf, b, c), math.inf) |
nothing calls this directly
no test coverage detected