[Numpy-discussion] nans and sort orders.
Charles R Harris
Tue Jul 28 12:41:50 CDT 2009
I've changed the sort routines so that they sort nans to the end. The sort
order is now
Real types: [R, nan]
Complex types: [R + Rj, R + nanj, nan + Rj, nan + nanj]
Where R stands for the usual extended range of reals, i.e. [-inf, finite,
+inf] and when two complex numbers have the same pattern of nans then they
are sorted on the non-nan part, if any.
So the sorts now work with nans but that implies some other fixups on which
I would like some feedback.
1) Search sorted -- Search sorted depends on the compare function of the
ndarray, I think that compare function should be changed to correspond to
the sort order.
2) Methods argmax/argmin/ -- should be compatible with max/min
3) max/min ufuncs -- Problematic, min would fail to propagate nans, should
probably stay the same.
4) fmax/fmin ufuncs -- Should stay with c definition
5) Logical comparison ufuncs -- I think these should remain compatible with
the c operators.
Note that there is a mix of implementations, max/min on void types use the
type comparison functions for instance. In other words, changing the type
comparisons could mean rewriting some of the other functions.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion