[Numpy-discussion] reciprocal(0)

Ralf Gommers ralf.gommers at googlemail.com
Sat Jun 6 23:49:36 EDT 2009


I expect `reciprocal(x)` to calculate 1/x, and for input 0 to either follow
the python rules or give the np.divide(1, 0) result. However the result
returned (with numpy trunk) is:

>>> np.reciprocal(0)

>>> np.divide(1, 0)
>>> 1/0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero

The result for a zero float argument is inf as expected. I want to document
the correct behavior for integers, what should it be?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090606/3667a1d0/attachment.html>

More information about the NumPy-Discussion mailing list