This is not a NumPy bug. numpy.inf is a regular Python float, and strange results come from the usual Python multiple multiplication algorithm, which this :
Py_complex _Py_c_prod(Py_complex a, Py_complex b) { Py_complex r; r.real = a.real*b.real - a.imag*b.imag; r.imag = a.real*b.imag + a.imag*b.real; return r; }
When inputs have infinite real or imaginary parts, complex multiplication tends to cause subtraction inf-inf and 0*inf multiplication, resulting in nan components as a result. We see that 1j * numpy.inf has one nan component and one inf component:
In [5]: 1j * numpy.inf Out[5]: (nan+infj)
and multiplying the result by 1 causes two nan components:
In [4]: 1j * numpy.inf * 1 Out[4]: (nan+nanj)
source share