[SciPy-user] Is numpy's argsort lying about its numpy.int32 types?

Travis Oliphant oliphant@ee.byu....
Wed Apr 18 18:28:51 CDT 2007


Rob Clewley wrote:

>Hi,
>
>I'm having a problem comparing some types when using numpy's argsort.
>I'm using numpy 1.0.2. I can reproduce it simply:
>  
>
>In [1]: from numpy import argsort, sort, int32, array
>
>In [2]: x=array([1,3,2])
>
>In [3]: aa=argsort(x)
>
>In [4]: as=sort(x)
>
>In [5]: type(aa[0])
>Out[5]: <type 'numpy.int32'>
>
>In [6]: type(as[0])
>Out[6]: <type 'numpy.int32'>
>
>In [7]: int32
>Out[7]: <type 'numpy.int32'>
>
>In [8]: type(as[0])==int32
>Out[8]: True
>
>In [9]: type(aa[0])==int32
>Out[9]: False
>
>Any of the three indices in aa give me the same problem. Can someone
>explain if I should be doing this a different way, and if this is a
>bug?!
>  
>

The "problem" is that there are two types that display as "int32" for 
some platforms (e.g. c_long and c_int are both numpy.int32 on my machine).

These are equivalent which can be seen by looking at the output of

aa.dtype == as.dtype


-Travis





More information about the SciPy-user mailing list