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

Kevin Jacobs <jacobs@bioinformed.com> bioinformed@gmail....
Wed Aug 13 16:36:20 CDT 2008


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

> On Wed, Aug 13, 2008 at 14:37, Joe Harrington <jh@physics.ucf.edu> wrote:
> >>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.
> >
> > 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://projects.scipy.org/pipermail/numpy-discussion/attachments/20080813/e481d295/attachment-0001.html 


More information about the Numpy-discussion mailing list