On Mon, Sep 29, 2008 at 9:02 PM, David Cournapeau < david@ar.media.kyoto-u.ac.jp> wrote:
Charles R Harris wrote:
So the proposition is, sign, max, min return nan when any of the arguments is nan.
Note that internally, signbit (the C function) returns an integer.
That is the signature of the ufunc. It could be changed... I believe the actual signbit of nan is undefined but I suppose we could return -1 in the nan case. That would be a fairly typical error signal for integers.
Complex numbers are more complicated because we first compare the real parts, then the imaginary. Arguably 1 > 0 + nan*1j.
Really ? Without thinking about the consequences, returning a NaN complex would be what I expect, should we go the route comparison with NaN returns a NaN.
Yeah, I'm headed that way also.
I propose that the sign of a complex number containing nans should be nan, but I can't decide what should happen with max/min
Did you take a look at:
http://projects.scipy.org/scipy/numpy/wiki/ProperNanHandling
Note that in my branch the current behavior is In [11]: a = np.array([0, np.nan, -1]) In [12]: np.max(a) Out[12]: nan In [13]: np.min(a) Out[13]: nan This is consistent with regarding nans as propagating errors. I can merge my branch back into yours if you want to play with these things. Chuck