@@ -2693,9 +2693,10 @@ def test_fma_nan_results(self):
26932693
26942694 # If any input is a NaN, the result should be a NaN, too.
26952695 for a , b in itertools .product (values , repeat = 2 ):
2696- self .assertIsNaN (math .fma (math .nan , a , b ))
2697- self .assertIsNaN (math .fma (a , math .nan , b ))
2698- self .assertIsNaN (math .fma (a , b , math .nan ))
2696+ with self .subTest (a = a , b = b ):
2697+ self .assertIsNaN (math .fma (math .nan , a , b ))
2698+ self .assertIsNaN (math .fma (a , math .nan , b ))
2699+ self .assertIsNaN (math .fma (a , b , math .nan ))
26992700
27002701 def test_fma_infinities (self ):
27012702 # Cases involving infinite inputs or results.
@@ -2707,57 +2708,62 @@ def test_fma_infinities(self):
27072708 for c in non_nans :
27082709 for infinity in [math .inf , - math .inf ]:
27092710 for zero in [0.0 , - 0.0 ]:
2710- with self .assertRaises (ValueError ):
2711- math .fma (infinity , zero , c )
2712- with self .assertRaises (ValueError ):
2713- math .fma (zero , infinity , c )
2711+ with self .subTest (c = c , infinity = infinity , zero = zero ):
2712+ with self .assertRaises (ValueError ):
2713+ math .fma (infinity , zero , c )
2714+ with self .assertRaises (ValueError ):
2715+ math .fma (zero , infinity , c )
27142716
27152717 # ValueError when a*b and c both infinite of opposite signs.
27162718 for b in positives :
2717- with self .assertRaises (ValueError ):
2718- math .fma (math .inf , b , - math .inf )
2719- with self .assertRaises (ValueError ):
2720- math .fma (math .inf , - b , math .inf )
2721- with self .assertRaises (ValueError ):
2722- math .fma (- math .inf , - b , - math .inf )
2723- with self .assertRaises (ValueError ):
2724- math .fma (- math .inf , b , math .inf )
2725- with self .assertRaises (ValueError ):
2726- math .fma (b , math .inf , - math .inf )
2727- with self .assertRaises (ValueError ):
2728- math .fma (- b , math .inf , math .inf )
2729- with self .assertRaises (ValueError ):
2730- math .fma (- b , - math .inf , - math .inf )
2731- with self .assertRaises (ValueError ):
2732- math .fma (b , - math .inf , math .inf )
2719+ with self .subTest (b = b ):
2720+ with self .assertRaises (ValueError ):
2721+ math .fma (math .inf , b , - math .inf )
2722+ with self .assertRaises (ValueError ):
2723+ math .fma (math .inf , - b , math .inf )
2724+ with self .assertRaises (ValueError ):
2725+ math .fma (- math .inf , - b , - math .inf )
2726+ with self .assertRaises (ValueError ):
2727+ math .fma (- math .inf , b , math .inf )
2728+ with self .assertRaises (ValueError ):
2729+ math .fma (b , math .inf , - math .inf )
2730+ with self .assertRaises (ValueError ):
2731+ math .fma (- b , math .inf , math .inf )
2732+ with self .assertRaises (ValueError ):
2733+ math .fma (- b , - math .inf , - math .inf )
2734+ with self .assertRaises (ValueError ):
2735+ math .fma (b , - math .inf , math .inf )
27332736
27342737 # Infinite result when a*b and c both infinite of the same sign.
27352738 for b in positives :
2736- self .assertEqual (math .fma (math .inf , b , math .inf ), math .inf )
2737- self .assertEqual (math .fma (math .inf , - b , - math .inf ), - math .inf )
2738- self .assertEqual (math .fma (- math .inf , - b , math .inf ), math .inf )
2739- self .assertEqual (math .fma (- math .inf , b , - math .inf ), - math .inf )
2740- self .assertEqual (math .fma (b , math .inf , math .inf ), math .inf )
2741- self .assertEqual (math .fma (- b , math .inf , - math .inf ), - math .inf )
2742- self .assertEqual (math .fma (- b , - math .inf , math .inf ), math .inf )
2743- self .assertEqual (math .fma (b , - math .inf , - math .inf ), - math .inf )
2739+ with self .subTest (b = b ):
2740+ self .assertEqual (math .fma (math .inf , b , math .inf ), math .inf )
2741+ self .assertEqual (math .fma (math .inf , - b , - math .inf ), - math .inf )
2742+ self .assertEqual (math .fma (- math .inf , - b , math .inf ), math .inf )
2743+ self .assertEqual (math .fma (- math .inf , b , - math .inf ), - math .inf )
2744+ self .assertEqual (math .fma (b , math .inf , math .inf ), math .inf )
2745+ self .assertEqual (math .fma (- b , math .inf , - math .inf ), - math .inf )
2746+ self .assertEqual (math .fma (- b , - math .inf , math .inf ), math .inf )
2747+ self .assertEqual (math .fma (b , - math .inf , - math .inf ), - math .inf )
27442748
27452749 # Infinite result when a*b finite, c infinite.
27462750 for a , b in itertools .product (finites , finites ):
2747- self .assertEqual (math .fma (a , b , math .inf ), math .inf )
2748- self .assertEqual (math .fma (a , b , - math .inf ), - math .inf )
2751+ with self .subTest (b = b ):
2752+ self .assertEqual (math .fma (a , b , math .inf ), math .inf )
2753+ self .assertEqual (math .fma (a , b , - math .inf ), - math .inf )
27492754
27502755 # Infinite result when a*b infinite, c finite.
27512756 for b , c in itertools .product (positives , finites ):
2752- self .assertEqual (math .fma (math .inf , b , c ), math .inf )
2753- self .assertEqual (math .fma (- math .inf , b , c ), - math .inf )
2754- self .assertEqual (math .fma (- math .inf , - b , c ), math .inf )
2755- self .assertEqual (math .fma (math .inf , - b , c ), - math .inf )
2757+ with self .subTest (b = b , c = c ):
2758+ self .assertEqual (math .fma (math .inf , b , c ), math .inf )
2759+ self .assertEqual (math .fma (- math .inf , b , c ), - math .inf )
2760+ self .assertEqual (math .fma (- math .inf , - b , c ), math .inf )
2761+ self .assertEqual (math .fma (math .inf , - b , c ), - math .inf )
27562762
2757- self .assertEqual (math .fma (b , math .inf , c ), math .inf )
2758- self .assertEqual (math .fma (b , - math .inf , c ), - math .inf )
2759- self .assertEqual (math .fma (- b , - math .inf , c ), math .inf )
2760- self .assertEqual (math .fma (- b , math .inf , c ), - math .inf )
2763+ self .assertEqual (math .fma (b , math .inf , c ), math .inf )
2764+ self .assertEqual (math .fma (b , - math .inf , c ), - math .inf )
2765+ self .assertEqual (math .fma (- b , - math .inf , c ), math .inf )
2766+ self .assertEqual (math .fma (- b , math .inf , c ), - math .inf )
27612767
27622768 # gh-73468: On some platforms, libc fma() doesn't implement IEE 754-2008
27632769 # properly: it doesn't use the right sign when the result is zero.
@@ -2770,23 +2776,24 @@ def test_fma_zero_result(self):
27702776
27712777 # Zero results from exact zero inputs.
27722778 for b in nonnegative_finites :
2773- self .assertIsPositiveZero (math .fma (0.0 , b , 0.0 ))
2774- self .assertIsPositiveZero (math .fma (0.0 , b , - 0.0 ))
2775- self .assertIsNegativeZero (math .fma (0.0 , - b , - 0.0 ))
2776- self .assertIsPositiveZero (math .fma (0.0 , - b , 0.0 ))
2777- self .assertIsPositiveZero (math .fma (- 0.0 , - b , 0.0 ))
2778- self .assertIsPositiveZero (math .fma (- 0.0 , - b , - 0.0 ))
2779- self .assertIsNegativeZero (math .fma (- 0.0 , b , - 0.0 ))
2780- self .assertIsPositiveZero (math .fma (- 0.0 , b , 0.0 ))
2781-
2782- self .assertIsPositiveZero (math .fma (b , 0.0 , 0.0 ))
2783- self .assertIsPositiveZero (math .fma (b , 0.0 , - 0.0 ))
2784- self .assertIsNegativeZero (math .fma (- b , 0.0 , - 0.0 ))
2785- self .assertIsPositiveZero (math .fma (- b , 0.0 , 0.0 ))
2786- self .assertIsPositiveZero (math .fma (- b , - 0.0 , 0.0 ))
2787- self .assertIsPositiveZero (math .fma (- b , - 0.0 , - 0.0 ))
2788- self .assertIsNegativeZero (math .fma (b , - 0.0 , - 0.0 ))
2789- self .assertIsPositiveZero (math .fma (b , - 0.0 , 0.0 ))
2779+ with self .subTest (b = b ):
2780+ self .assertIsPositiveZero (math .fma (0.0 , b , 0.0 ))
2781+ self .assertIsPositiveZero (math .fma (0.0 , b , - 0.0 ))
2782+ self .assertIsNegativeZero (math .fma (0.0 , - b , - 0.0 ))
2783+ self .assertIsPositiveZero (math .fma (0.0 , - b , 0.0 ))
2784+ self .assertIsPositiveZero (math .fma (- 0.0 , - b , 0.0 ))
2785+ self .assertIsPositiveZero (math .fma (- 0.0 , - b , - 0.0 ))
2786+ self .assertIsNegativeZero (math .fma (- 0.0 , b , - 0.0 ))
2787+ self .assertIsPositiveZero (math .fma (- 0.0 , b , 0.0 ))
2788+
2789+ self .assertIsPositiveZero (math .fma (b , 0.0 , 0.0 ))
2790+ self .assertIsPositiveZero (math .fma (b , 0.0 , - 0.0 ))
2791+ self .assertIsNegativeZero (math .fma (- b , 0.0 , - 0.0 ))
2792+ self .assertIsPositiveZero (math .fma (- b , 0.0 , 0.0 ))
2793+ self .assertIsPositiveZero (math .fma (- b , - 0.0 , 0.0 ))
2794+ self .assertIsPositiveZero (math .fma (- b , - 0.0 , - 0.0 ))
2795+ self .assertIsNegativeZero (math .fma (b , - 0.0 , - 0.0 ))
2796+ self .assertIsPositiveZero (math .fma (b , - 0.0 , 0.0 ))
27902797
27912798 # Exact zero result from nonzero inputs.
27922799 self .assertIsPositiveZero (math .fma (2.0 , 2.0 , - 4.0 ))
@@ -2892,12 +2899,14 @@ def test_random(self):
28922899 '0x1.f5467b1911fd6p-2' , '0x1.b5cee3225caa5p-1' ),
28932900 ]
28942901 for a_hex , b_hex , c_hex , expected_hex in test_values :
2895- a = float .fromhex (a_hex )
2896- b = float .fromhex (b_hex )
2897- c = float .fromhex (c_hex )
2898- expected = float .fromhex (expected_hex )
2899- self .assertEqual (math .fma (a , b , c ), expected )
2900- self .assertEqual (math .fma (b , a , c ), expected )
2902+ with self .subTest (a_hex = a_hex , b_hex = b_hex , c_hex = c_hex ,
2903+ expected_hex = expected_hex ):
2904+ a = float .fromhex (a_hex )
2905+ b = float .fromhex (b_hex )
2906+ c = float .fromhex (c_hex )
2907+ expected = float .fromhex (expected_hex )
2908+ self .assertEqual (math .fma (a , b , c ), expected )
2909+ self .assertEqual (math .fma (b , a , c ), expected )
29012910
29022911 # Custom assertions.
29032912 def assertIsNaN (self , value ):
0 commit comments