-
-
Notifications
You must be signed in to change notification settings - Fork 12k
Open
Description
Describe the issue:
The Array API spec has the following special case __pow__()/ __ipow__()
If
x1_iis-0,x2_iis greater than0, andx2_iis not an odd integer value, the result is+0.
array_api arrays currently follow this special case for __pow__()—__ipow__() seems to likewise follow this case except when x2_i=.5, where a negative 0 is returned instead. cc @asmeurer @seberg
Also discovered a similar problem when self=-inf #21213 (comment)
Reproduce the code example:
>>> x1 = xp.asarray(-0.)
>>> x2 = xp.asarray(0.5)
>>> x1 ** x2
Array(0., dtype=float64)
>>> x1 **= x2
>>> x1
Array(-0., dtype=float64) # should be positive 0
...
>>> x3 = xp.asarray(-0.)
>>> x4 = xp.asarray(2.)
>>> x3 **= x4; x3
Array(0., dtype=float64) # as expected
...
>>> x5 = xp.asarray(-0.)
>>> x6 = xp.asarray(2.5)
>>> x5 **= x6; x5
Array(0., dtype=float64) # as expected
...
>>> x7 = xp.asarray(-0.)
>>> x8 = xp.asarray(.6)
>>> x7 **= x8; x7
Array(0., dtype=float64) # as expectedError message:
No response
NumPy/Python version information:
1.22.3 3.8.12 (default, Mar 13 2022, 19:12:08)
[GCC 9.4.0]