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

Charles R Harris charlesr.harris at gmail.com
Fri Oct 3 10:30:12 EDT 2014


On Fri, Oct 3, 2014 at 1:33 AM, Stephan Hoyer <shoyer at gmail.com> wrote:

> 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.
>
>
> +1
>
> 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
> array([-9223372036854775808])
>

This will be an error in 1.10

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141003/d069c6bc/attachment.html>


More information about the NumPy-Discussion mailing list