File tree 2 files changed +8
-4
lines changed 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -917,14 +917,14 @@ NPY_NO_EXPORT void
917
917
@type @ in2 = * (@type @ * )ip2 ;
918
918
@type @ out ;
919
919
920
+ if (in2 == 0 ) {
921
+ * ((@type @ * )op1 ) = 1 ;
922
+ continue ;
923
+ }
920
924
if (in2 < 0 || in1 == 0 ) {
921
925
* ((@type @ * )op1 ) = 0 ;
922
926
continue ;
923
927
}
924
- if (in2 == 0 ) {
925
- * ((@type @ * )op1 ) = 1 ;
926
- continue ;
927
- }
928
928
929
929
out = in2 & 1 ? in1 : 1 ;
930
930
in2 >>= 1 ;
Original file line number Diff line number Diff line change @@ -430,6 +430,10 @@ def test_integer_power(self):
430
430
b = a ** a
431
431
assert_equal (b , [437893890380859375 , 437893890380859375 ])
432
432
433
+ def test_integer_power_with_zero_exponent (self ):
434
+ arr = np .arange (- 10 , 10 )
435
+ assert_equal (np .power (arr , 0 ), np .ones_like (arr ))
436
+
433
437
434
438
class TestLog2 (TestCase ):
435
439
def test_log2_values (self ):
You can’t perform that action at this time.
0 commit comments