[Numpy-discussion] Any and all NaNs

Keith Goodman kwgoodman at gmail.com
Thu May 29 13:53:30 EDT 2008


On Thu, May 29, 2008 at 9:26 AM, Stéfan van der Walt <stefan at sun.ac.za> wrote:
> 2008/5/23 Keith Goodman <kwgoodman at gmail.com>:
>> On Fri, May 23, 2008 at 11:44 AM, Robert Kern <robert.kern at gmail.com> wrote:
>>> On Fri, May 23, 2008 at 12:22 PM, Keith Goodman <kwgoodman at gmail.com> wrote:
>>>
>>>> But the first example
>>>>
>>>>>> x = mp.matrix([[mp.nan]])
>>>>>> x
>>>>   matrix([[ NaN]])
>>>>>> x.all()
>>>>   True
>>>>>> x.any()
>>>>   True
>>>>
>>>> is still surprising.
>>>
>>> On non-boolean arrays, .all() and .any() check each element to see if
>>> it is not equal to 0. NaN != 0. Returning False would be just as
>>> wrong. If there were a Maybe in addition to True and False, then
>>> perhaps that would be worth changing, but I don't see a reason to
>>> change the rule as it is.
>>
>> That makes sense. Hopefully it will find its way into the doc string.
>
> Hopefully you'll add it there :)
>
> Cheers
> Stéfan

My username is kwgoodman.



More information about the NumPy-Discussion mailing list