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

Robert Kern robert.kern@gmail....
Tue Aug 12 20:59:11 CDT 2008


On Tue, Aug 12, 2008 at 19:28, Charles R Harris
<charlesr.harris@gmail.com> wrote:
>
>
> On Tue, Aug 12, 2008 at 5:13 PM, Andrew Dalke <dalke@dalkescientific.com>
> wrote:
>>
>> On Aug 12, 2008, at 9:54 AM, Anne Archibald wrote:
>> > 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.
>
> <snip>
>
>>
>> Personally, I expect that if my array 'x' has a NaN then
>> min(x) must be a NaN.
>
> I suppose you could use
>
> min(a,b) = (abs(a - b) + a + b)/2
>
> which would have that effect.

Or we could implement the inner loop of the minimum ufunc to return
NaN if there is a NaN. Currently it just compares the two values
(which causes the unpredictable results since having a NaN on either
side of the < is always False). I would be amenable to that provided
that the C isnan() call does not cause too much slowdown in the normal
case.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco


More information about the Numpy-discussion mailing list