On 09/29/2015 11:39 AM, josef.p...@gmail.com wrote: > > > On Tue, Sep 29, 2015 at 11:25 AM, Anne Archibald <archib...@astron.nl > <mailto:archib...@astron.nl>> wrote: > > IEEE 754 has signum(NaN)->NaN. So does np.sign on floating-point > arrays. Why should it be different for object arrays? > > Anne > > P.S. If you want exceptions when NaNs appear, that's what np.seterr > is for. -A > > > > I also think NaN should be treated the same way as floating point > numbers (whatever that is). Otherwise it is difficult to remember when > nan is essentially a float dtype or another dtype. > (given that float is the smallest dtype that can hold a nan) >
Note that I've reimplemented np.sign for object arrays along these lines in this open PR: https://github.com/numpy/numpy/pull/6320 That PR recursively uses the np.sign ufunc to evaluate object arrays containing float and complex numbers. This way the behavior on object arrays is identical to float/complex arrays. Here is what the np.sign ufunc does (for arbitrary x): np.sign(np.nan) -> nan np.sign(complex(np.nan, x)) -> complex(nan, 0) np.sign(complex(x, np.nan)) -> complex(nan, 0) Allan _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion