(self)
| 2709 | self.assertIsNaN(math.fma(a, b, math.nan)) |
| 2710 | |
| 2711 | def test_fma_infinities(self): |
| 2712 | # Cases involving infinite inputs or results. |
| 2713 | positives = [1e-300, 2.3, 1e300, math.inf] |
| 2714 | finites = [-1e300, -2.3, -1e-300, -0.0, 0.0, 1e-300, 2.3, 1e300] |
| 2715 | non_nans = [-math.inf, -2.3, -0.0, 0.0, 2.3, math.inf] |
| 2716 | |
| 2717 | # ValueError due to inf * 0 computation. |
| 2718 | for c in non_nans: |
| 2719 | for infinity in [math.inf, -math.inf]: |
| 2720 | for zero in [0.0, -0.0]: |
| 2721 | with self.subTest(c=c, infinity=infinity, zero=zero): |
| 2722 | with self.assertRaises(ValueError): |
| 2723 | math.fma(infinity, zero, c) |
| 2724 | with self.assertRaises(ValueError): |
| 2725 | math.fma(zero, infinity, c) |
| 2726 | |
| 2727 | # ValueError when a*b and c both infinite of opposite signs. |
| 2728 | for b in positives: |
| 2729 | with self.subTest(b=b): |
| 2730 | with self.assertRaises(ValueError): |
| 2731 | math.fma(math.inf, b, -math.inf) |
| 2732 | with self.assertRaises(ValueError): |
| 2733 | math.fma(math.inf, -b, math.inf) |
| 2734 | with self.assertRaises(ValueError): |
| 2735 | math.fma(-math.inf, -b, -math.inf) |
| 2736 | with self.assertRaises(ValueError): |
| 2737 | math.fma(-math.inf, b, math.inf) |
| 2738 | with self.assertRaises(ValueError): |
| 2739 | math.fma(b, math.inf, -math.inf) |
| 2740 | with self.assertRaises(ValueError): |
| 2741 | math.fma(-b, math.inf, math.inf) |
| 2742 | with self.assertRaises(ValueError): |
| 2743 | math.fma(-b, -math.inf, -math.inf) |
| 2744 | with self.assertRaises(ValueError): |
| 2745 | math.fma(b, -math.inf, math.inf) |
| 2746 | |
| 2747 | # Infinite result when a*b and c both infinite of the same sign. |
| 2748 | for b in positives: |
| 2749 | with self.subTest(b=b): |
| 2750 | self.assertEqual(math.fma(math.inf, b, math.inf), math.inf) |
| 2751 | self.assertEqual(math.fma(math.inf, -b, -math.inf), -math.inf) |
| 2752 | self.assertEqual(math.fma(-math.inf, -b, math.inf), math.inf) |
| 2753 | self.assertEqual(math.fma(-math.inf, b, -math.inf), -math.inf) |
| 2754 | self.assertEqual(math.fma(b, math.inf, math.inf), math.inf) |
| 2755 | self.assertEqual(math.fma(-b, math.inf, -math.inf), -math.inf) |
| 2756 | self.assertEqual(math.fma(-b, -math.inf, math.inf), math.inf) |
| 2757 | self.assertEqual(math.fma(b, -math.inf, -math.inf), -math.inf) |
| 2758 | |
| 2759 | # Infinite result when a*b finite, c infinite. |
| 2760 | for a, b in itertools.product(finites, finites): |
| 2761 | with self.subTest(b=b): |
| 2762 | self.assertEqual(math.fma(a, b, math.inf), math.inf) |
| 2763 | self.assertEqual(math.fma(a, b, -math.inf), -math.inf) |
| 2764 | |
| 2765 | # Infinite result when a*b infinite, c finite. |
| 2766 | for b, c in itertools.product(positives, finites): |
| 2767 | with self.subTest(b=b, c=c): |
| 2768 | self.assertEqual(math.fma(math.inf, b, c), math.inf) |
nothing calls this directly
no test coverage detected