[Numpy-discussion] What is the sign of nan?
Charles R Harris
Mon Sep 29 23:02:54 CDT 2008
On Mon, Sep 29, 2008 at 9:02 PM, David Cournapeau <
> 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:
Note that in my branch the current behavior is
In : a = np.array([0, np.nan, -1])
In : np.max(a)
In : np.min(a)
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion