[Numpy-discussion] sorting -inf, nan, inf
ndarray at mac.com
Tue Sep 19 14:57:22 CDT 2006
On 9/19/06, Tim Hochberg <tim.hochberg at ieee.org> wrote:
> Ideally, -inf should sort first, inf should sort last and nan should
> raise an exception if present.
I disagree. NumPy sort leaving nan's where they are is probably just a
side-effect of nans unusual properties (both nan<x and nan>x is always
false), but it is a logical choice. Checking for nan will inevitably
slow the most common use case. If you want an exception, just check
isnan(x).any() before sort.
More information about the Numpy-discussion