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

Eelco Hoogendoorn hoogendoorn.eelco at gmail.com
Fri Oct 3 02:51:50 EDT 2014


slightly OT; but fwiw, its all ill-thought out nonsense from the start
anyway.

ALL numbers satisfy the predicate 0*x=0. what the IEEE calls 'not a
number' would be more accurately called 'not a specific number', or 'a
number'. whats a logical negation among computer scientists?

On Fri, Oct 3, 2014 at 6:13 AM, Charles R Harris <charlesr.harris at gmail.com>
wrote:

>
>
> On Thu, Oct 2, 2014 at 10:12 PM, Charles R Harris <
> charlesr.harris at gmail.com> wrote:
>
>>
>>
>> On Thu, Oct 2, 2014 at 9:29 PM, Nathaniel Smith <njs at pobox.com> wrote:
>>
>>> On Fri, Oct 3, 2014 at 3:20 AM, Charles R Harris
>>> <charlesr.harris at gmail.com> wrote:
>>> >
>>> > On Thu, Oct 2, 2014 at 7:06 PM, Benjamin Root <ben.root at ou.edu> wrote:
>>> >>
>>> >> Out[1] has an integer divided by an integer, and you can't represent
>>> nan
>>> >> as an integer. Perhaps something weird was happening with type
>>> promotion
>>> >> between versions?
>>> >
>>> >
>>> > Also note that in python3 the '/' operator does float rather than
>>> integer
>>> > division.
>>> >
>>> >>>> np.array(0) / np.array(0)
>>> > __main__:1: RuntimeWarning: invalid value encountered in true_divide
>>> > nan
>>>
>>> Floor division still acts the same though:
>>>
>>> >>> np.array(0) // np.array(0)
>>> __main__:1: RuntimeWarning: divide by zero encountered in floor_divide
>>> 0
>>>
>>> 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.
>>>
>>
>> That's an option, although arguable for arrays of numbers. However, the
>> fact that we don't know *which* numbers caused the problem strengthens the
>> argument for an error.
>>
>>
> Plus the g*dawful warning default to only warn once. That has always
> bothered me, it just seems useless.
>
> Chuck
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141003/0b6326e1/attachment.html>


More information about the NumPy-Discussion mailing list