@@ -372,11 +372,18 @@ def test_scalar(self):
372
372
x = np .array ([1 , 1j , 2 , 2.5 + .37j , np .inf , np .nan ])
373
373
y = np .array ([1 , 1j , - 0.5 + 1.5j , - 0.5 + 1.5j , 2 , 3 ])
374
374
lx = list (range (len (x )))
375
- # Compute the values for complex type in python
376
- p_r = [complex (x [i ]) ** complex (y [i ]) for i in lx ]
377
- # Substitute a result allowed by C99 standard
378
- p_r [4 ] = complex (np .inf , np .nan )
379
- # Do the same with numpy complex scalars
375
+
376
+ # Hardcode the expected `builtins.complex` values,
377
+ # as complex exponentiation is broken as of bpo-44698
378
+ p_r = [
379
+ 1 + 0j ,
380
+ 0.20787957635076193 + 0j ,
381
+ 0.35812203996480685 + 0.6097119028618724j ,
382
+ 0.12659112128185032 + 0.48847676699581527j ,
383
+ complex (np .inf , np .nan ),
384
+ complex (np .nan , np .nan ),
385
+ ]
386
+
380
387
n_r = [x [i ] ** y [i ] for i in lx ]
381
388
for i in lx :
382
389
assert_almost_equal (n_r [i ], p_r [i ], err_msg = 'Loop %d\n ' % i )
@@ -385,11 +392,18 @@ def test_array(self):
385
392
x = np .array ([1 , 1j , 2 , 2.5 + .37j , np .inf , np .nan ])
386
393
y = np .array ([1 , 1j , - 0.5 + 1.5j , - 0.5 + 1.5j , 2 , 3 ])
387
394
lx = list (range (len (x )))
388
- # Compute the values for complex type in python
389
- p_r = [complex (x [i ]) ** complex (y [i ]) for i in lx ]
390
- # Substitute a result allowed by C99 standard
391
- p_r [4 ] = complex (np .inf , np .nan )
392
- # Do the same with numpy arrays
395
+
396
+ # Hardcode the expected `builtins.complex` values,
397
+ # as complex exponentiation is broken as of bpo-44698
398
+ p_r = [
399
+ 1 + 0j ,
400
+ 0.20787957635076193 + 0j ,
401
+ 0.35812203996480685 + 0.6097119028618724j ,
402
+ 0.12659112128185032 + 0.48847676699581527j ,
403
+ complex (np .inf , np .nan ),
404
+ complex (np .nan , np .nan ),
405
+ ]
406
+
393
407
n_r = x ** y
394
408
for i in lx :
395
409
assert_almost_equal (n_r [i ], p_r [i ], err_msg = 'Loop %d\n ' % i )
@@ -583,7 +597,7 @@ class TestComplexAbsoluteMixedDTypes:
583
597
@pytest .mark .parametrize ("stride" , [- 4 ,- 3 ,- 2 ,- 1 ,1 ,2 ,3 ,4 ])
584
598
@pytest .mark .parametrize ("astype" , [np .complex64 , np .complex128 ])
585
599
@pytest .mark .parametrize ("func" , ['abs' , 'square' , 'conjugate' ])
586
-
600
+
587
601
def test_array (self , stride , astype , func ):
588
602
dtype = [('template_id' , '<i8' ), ('bank_chisq' ,'<f4' ),
589
603
('bank_chisq_dof' ,'<i8' ), ('chisq' , '<f4' ), ('chisq_dof' ,'<i8' ),
@@ -602,9 +616,9 @@ def test_array(self, stride, astype, func):
602
616
myfunc = getattr (np , func )
603
617
a = vec ['mycomplex' ]
604
618
g = myfunc (a [::stride ])
605
-
619
+
606
620
b = vec ['mycomplex' ].copy ()
607
621
h = myfunc (b [::stride ])
608
-
622
+
609
623
assert_array_max_ulp (h .real , g .real , 1 )
610
624
assert_array_max_ulp (h .imag , g .imag , 1 )
0 commit comments