[Numpy-discussion] sorting -inf, nan, inf
Charles R Harris
charlesr.harris at gmail.com
Tue Sep 19 14:52:01 CDT 2006
On 9/19/06, Tim Hochberg <tim.hochberg at ieee.org> wrote:
> Keith Goodman wrote:
> > In what order would you like argsort to sort the values -inf, nan, inf?
> Ideally, -inf should sort first, inf should sort last and nan should
> raise an exception if present.
That sounds right. Nan can't be compared because, well, it is undefined. For
In : a = arange(2)
In : a/0
Out: array([0, 0])
In : a/0.0
Out: array([ nan, inf])
In : a/(-0.0)
Out: array([ nan, -inf])
I.e., 0.0/0.0 is undefined. But unless the hardware generates the exception
I would be loath to introduce checks in the code. Putting a check in the
innermost loop of the sorts would cost significant time.
But look at the integer division by zero where the IEEE stuff has no
relevence. That sure looks like a bug to me.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion