[Numpy-discussion] min() of array containing NaN

Anne Archibald peridot.faceted@gmail....
Tue Aug 12 02:54:32 CDT 2008


2008/8/12 Stéfan van der Walt <stefan@sun.ac.za>:
> Hi Andrew
>
> 2008/8/12 Andrew Dalke <dalke@dalkescientific.com>:
>> This is buggy for the case of a list containing only NaNs.
>>
>>  >>> import numpy as np
>>  >>> np.NAN
>> nan
>>  >>> np.min([np.NAN])
>> nan
>>  >>> np.nanmin([np.NAN])
>> inf
>>  >>>
>
> Thanks for the report.  This should be fixed in r5630.

Er, is this actually a bug? I would instead consider the fact that
np.min([]) raises an exception a bug of sorts - the identity of min is
inf. Really nanmin of an array containing only nans should be the same
as an empty array; both should be infinity.

I guess this is a problem for types that don't have an infinity
(returning maxint is a poor substitute), but what is the correct
behaviour here?

Anne


More information about the Numpy-discussion mailing list