[Numpy-discussion] Proper NaN handling in max and co: a redux

Anne Archibald peridot.faceted@gmail....
Fri Sep 26 11:00:57 CDT 2008


2008/9/26 David Cournapeau <david@ar.media.kyoto-u.ac.jp>:
> Charles R Harris wrote:
>>
>> I'm also wondering about the sign ufunc. It should probably return nan
>> for nans, but -1,0,1 are the current values. We also need to decide
>> which end of the sorted values the nans should go to. I'm a bit
>> partial to the beginning but the end would be fine with me, it might
>> even be a bit more natural as searchsorted would find the beginning of
>> the nans by default.

I would think sign should return NaN (does it not now?) unless its
return type is integer, in which case I can't see a better answer than
raising an exception (we certainly don't want it silently swallowing
NaNs).

> Note that in both suggest approaches, sort with NaN would raise an
> error. We could then provide a nansort, which ignore the NaN, and deal
> with your case; would it be hard to have an option for the beginning vs
> the end, or would that be difficult ?

Is it really a good idea to duplicate the maskedarray sorting code?

Anne


More information about the Numpy-discussion mailing list