[Numpy-discussion] Who will use numpy.ma?

Travis Oliphant oliphant.travis at ieee.org
Thu Jan 12 16:47:02 CST 2006


Joris De Ridder wrote:

>>>>y = array([1, nan, 0.47])
>>>>sort(y)
>>>>        
>>>>
>array([ 1.        ,         nan,  0.47      ])
>
>No exception, no sorting. Is this a feature or a bug? :)
>  
>
It's a "problem" that the user needs to be aware of, but I'm not sure 
how to fix.

Notice that the same problem exists with python
try:

b =y.tolist()
b.sort()

Same effect.

The problem may be that nans are always False on comparison with another 
object and this ends up confusing the sort functions. 

To fix it we would have to write a special nan-sort or else remove the 
nans entirely, but I don't think we should check for nans for every sort 
of floating-point values, because it would be slower.  So, the user 
needs to do that.

-Travis






More information about the Numpy-discussion mailing list