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

Kevin Jacobs <jacobs@bioinformed.com> bioinformed at gmail.com
Wed Aug 13 17:36:20 EDT 2008


On Wed, Aug 13, 2008 at 4:01 PM, Robert Kern <robert.kern at gmail.com> wrote:

> On Wed, Aug 13, 2008 at 14:37, Joe Harrington <jh at physics.ucf.edu> wrote:
> >>On Tue, Aug 12, 2008 at 19:28, Charles R Harris
> >><charlesr.harris at gmail.com> wrote:
> >>>
> >>>
> >>> On Tue, Aug 12, 2008 at 5:13 PM, Andrew Dalke <
> dalke at 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.
> >
> > While you're doing that, can you do it so that if keyword nan=False it
> > returns NaN if NaNs exist, and if keyword nan=True it ignores NaNs?
>
> I'm doing nothing. Someone else must volunteer.
>


I've volunteered to implement this functionality and will have some time
over the weekend to prepare and post a patch for further discussion.

-Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080813/e481d295/attachment.html>


More information about the NumPy-Discussion mailing list