32bit integers as list indices

Neilen Marais nmarais at sun.ac.za
Tue Nov 14 08:37:52 CST 2006


Hi,

I'm not sure if the following is expected to work on a 64bit machine:

In [381]: import numpy as N
In [382]: l = range(3)
In [383]: i32 = N.array([0,2], N.int32)
In [384]: i64 = N.array([0,2], N.int64)
In [385]: l[i32[0]]
---------------------------------------------------------------------------
exceptions.TypeError                           Traceback (most recent call last)

/home/brick/akademie/NewCode/working/<ipython console> 

TypeError: list indices must be integers

In [386]: l[i64[0]]
Out[386]: 0

I'd expect the 32-bit indices to work since they can be upcast to 64bit without
loss. Am I silly for thinking this way, or is it something numpy can/should
address? This came up while working with sparse matrices:

http://projects.scipy.org/scipy/scipy/ticket/307

Regards
Neilen

-- 
you know its kind of tragic 
we live in the new world
but we've lost the magic
-- Battery 9 (www.battery9.co.za)


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642




More information about the Numpy-discussion mailing list