[Numpy-discussion] 0/0 == 0?

Stephan Hoyer shoyer at gmail.com
Fri Oct 3 03:33:50 EDT 2014

On Thu, Oct 2, 2014 at 11:29 PM, Nathaniel Smith <njs at pobox.com> wrote:

> The seterr warning system makes a lot of sense for IEEE754 floats,
> which are specifically designed so that 0/0 has a unique well-defined
> answer. For ints though this seems really broken to me. 0 / 0 = 0 is
> just the wrong answer. It would be nice if we had something reasonable
> to return, but we don't, and I'd rather raise an error than return the
> wrong answer.


An even worse offender (in my opinion) is in-place addition of an integer
array with np.nan:

>>> x = np.zeros(1, dtype=int)
>>> x += np.nan
RuntimeWarning: invalid value encountered in add
>>> x
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141003/f79e5e12/attachment.html>

More information about the NumPy-Discussion mailing list