Open
Description
numpy.reciprocal(a)
and 1 / a
give different results with a = numpy.array(0 + 0j)
. reciprocal
gives nan+nanj
, and 1 / a
gives inf+nanj
.
It seems like neither of these results is correct, but I could certainly be wrong. I feel like the result in both cases should be inf+0j
, since we get inf
when we use real numbers: 1 / numpy.array(0.0)
and numpy.reciprocal(numpy.array(0.0))
.
Reproducing code example:
>>> import numpy
>>> a = numpy.array(0 + 0j)
__main__:1: RuntimeWarning: invalid value encountered in reciprocal
>>> numpy.reciprocal(a)
(nan+nanj)
>>> 1 / a
(inf+nanj)
>>> 1 / numpy.array(0.0)
inf
>>> numpy.reciprocal(numpy.array(0.0))
__main__:1: RuntimeWarning: divide by zero encountered in reciprocal
inf
NumPy/Python version information:
>>> print(numpy.__version__, sys.version)
1.18.1 3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0]
OS
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
Metadata
Metadata
Assignees
Labels
No labels