@@ -430,30 +430,41 @@ def test_pow_with_small_integer_exponents(self):
430430
431431 # Check that complex numbers with special components
432432 # are correctly handled.
433- for x in [2 , - 2 , + 0.0 , - 0.0 , INF , - INF , NAN ]:
434- for y in [2 , - 2 , + 0.0 , - 0.0 , INF , - INF , NAN ]:
435- c = complex (x , y )
436- with self .subTest (c ):
437- self .assertComplexesAreIdentical (c ** 0 , complex (1 , + 0.0 ))
438- self .assertComplexesAreIdentical (c ** 1 , c )
439- self .assertComplexesAreIdentical (c ** 2 , c * c )
440- self .assertComplexesAreIdentical (c ** 3 , c * (c * c ))
441- self .assertComplexesAreIdentical (c ** 4 , (c * c )* (c * c ))
442- self .assertComplexesAreIdentical (c ** 5 , c * ((c * c )* (c * c )))
433+ values = [complex (x , y )
434+ for x in [5 , - 5 , + 0.0 , - 0.0 , INF , - INF , NAN ]
435+ for y in [12 , - 12 , + 0.0 , - 0.0 , INF , - INF , NAN ]]
436+ for c in values :
437+ with self .subTest (value = c ):
438+ self .assertComplexesAreIdentical (c ** 0 , complex (1 , + 0.0 ))
439+ self .assertComplexesAreIdentical (c ** 1 , c )
440+ self .assertComplexesAreIdentical (c ** 2 , c * c )
441+ self .assertComplexesAreIdentical (c ** 3 , c * (c * c ))
442+ self .assertComplexesAreIdentical (c ** 4 , (c * c )* (c * c ))
443+ self .assertComplexesAreIdentical (c ** 5 , c * ((c * c )* (c * c )))
444+ self .assertComplexesAreIdentical (c ** 6 , (c * c )* ((c * c )* (c * c )))
445+ self .assertComplexesAreIdentical (c ** 7 , c * (c * c )* ((c * c )* (c * c )))
446+ self .assertComplexesAreIdentical (c ** 8 , ((c * c )* (c * c ))* ((c * c )* (c * c )))
447+ if not c :
448+ continue
449+ for n in range (1 , 9 ):
450+ with self .subTest (exponent = - n ):
451+ self .assertComplexesAreIdentical (c ** - n , 1 / (c ** n ))
443452 for x in [+ 2 , - 2 ]:
444453 for y in [+ 0.0 , - 0.0 ]:
445- with self .subTest (complex (x , y )):
446- self .assertComplexesAreIdentical (complex (x , y )** - 1 , complex (1 / x , - y ))
447- with self .subTest (complex (y , x )):
448- self .assertComplexesAreIdentical (complex (y , x )** - 1 , complex (y , - 1 / x ))
454+ c = complex (x , y )
455+ with self .subTest (value = c ):
456+ self .assertComplexesAreIdentical (c ** - 1 , complex (1 / x , - y ))
457+ c = complex (y , x )
458+ with self .subTest (value = c ):
459+ self .assertComplexesAreIdentical (c ** - 1 , complex (y , - 1 / x ))
449460 for x in [+ INF , - INF ]:
450461 for y in [+ 1 , - 1 ]:
451462 c = complex (x , y )
452- with self .subTest (c ):
463+ with self .subTest (value = c ):
453464 self .assertComplexesAreIdentical (c ** - 1 , complex (1 / x , - 0.0 * y ))
454465 self .assertComplexesAreIdentical (c ** - 2 , complex (0.0 , - y / x ))
455466 c = complex (y , x )
456- with self .subTest (c ):
467+ with self .subTest (value = c ):
457468 self .assertComplexesAreIdentical (c ** - 1 , complex (+ 0.0 * y , - 1 / x ))
458469 self .assertComplexesAreIdentical (c ** - 2 , complex (- 0.0 , - y / x ))
459470
0 commit comments