[Numpy-discussion] Complex zerodivision/negative powers not handled correctly

Jörgen Stenarson jorgen.stenarson@bostream...
Tue Dec 8 11:54:37 CST 2009


I have observed a problem with complex zerodivision and negative powers.
With a complex zero the result is either zero or NaN NaNj, the first one 
is clearly wrong and the other one I don't know what is most reasonable 
some kind of inf or a Nan.

This problem has been reported in the tracker as #1271.

In [1]: import numpy

In [2]: numpy.__version__
Out[2]: '1.4.0rc1'

In [3]: from numpy import *

In [4]: array([-0., 0])**-1
Out[4]: array([-Inf,  Inf])

In [5]: array([-0., 0])**-2
Out[5]: array([ Inf,  Inf])

In [6]: array([-0.-0j, -0.+0j, 0-0j, 0+0j])**-2
Out[6]: array([ 0.+0.j,  0.+0.j,  0.+0.j,  0.+0.j])

In [7]: array([-0.-0j, -0.+0j, 0-0j, 0+0j])**-1
Out[7]: array([ NaN NaNj,  NaN NaNj,  NaN NaNj,  NaN NaNj])

In [8]: 1/array([-0.-0j, -0.+0j, 0-0j, 0+0j])
Out[8]: array([ NaN NaNj,  NaN NaNj,  NaN NaNj,  NaN NaNj])

More information about the NumPy-Discussion mailing list