[Numpy-discussion] sorting -inf, nan, inf

Tim Hochberg tim.hochberg at ieee.org
Tue Sep 19 14:40:04 CDT 2006


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.

-tim


> In numpy 1.0b1 nan is always left where it began:
>
> EXAMPLE 1
>
>   
>>> x
>>>       
>
> matrix([[              inf],
>         [             -inf],
>         [              nan]])
>   
>>> x[x.argsort(0),:]
>>>       
>
> matrix([[             -inf],
>         [              inf],
>         [              nan]])
>
> EXAMPLE 2
>
>   
>>> x
>>>       
>
> matrix([[                  nan],
>         [                  inf],
>         [                 -inf]])
>   
>>> x[x.argsort(0),:]
>>>       
>
> matrix([[                  nan],
>         [                 -inf],
>         [                  inf]])
>
>
> I would like nan to be in the middle between -inf and inf.
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>
>   






More information about the Numpy-discussion mailing list