[Numpy-discussion] nan, sign, and all that
Charles R Harris
charlesr.harris@gmail....
Thu Oct 2 01:03:43 CDT 2008
Hi All,
I've added ufuncs fmin and fmax that behave as follows:
In [3]: a = array([NAN, 0, NAN, 1])
In [4]: b = array([0, NAN, NAN, 0])
In [5]: fmax(a,b)
Out[5]: array([ 0., 0., NaN, 1.])
In [6]: fmin(a,b)
Out[6]: array([ 0., 0., NaN, 0.])
In [7]: fmax.reduce(a)
Out[7]: 1.0
In [8]: fmin.reduce(a)
Out[8]: 0.0
In [9]: fmax.reduce([NAN,NAN])
Out[9]: nan
In [10]: fmin.reduce([NAN,NAN])
Out[10]: nan
I also made the sign ufunc return the sign of nan. That works, but I'm not
sure it is the way to go because there doesn't seem to be any spec as to
what sign nan takes. The current np.nan on my machine is negative and 0/0,
inf/inf all return negative nan. So it doesn't look like the actual sign of
nan makes any sense. Currently sign(NAN) returns 0, which doesn't look right
either, so I think the thing to do is return nan but this will be a change
in numpy behavior. Any thoughts?
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20081002/e5f55bbf/attachment.html
More information about the Numpy-discussion
mailing list