[Numpy-discussion] argmax() return type can't index python lists

Zachary Pincus zpincus at stanford.edu
Thu Mar 9 15:55:04 CST 2006

Hi folks,

I'm using a fresh build of numpy and python 2.5, both checked out  
from SVN yesterday. It seems that numpy.argmax() and ndarray.argmax()  
are now returning 'int32scalar' types instead of 'int' types. Despite  
the fact that the former seems to inherit from the latter,  
'int32scalar' types do not appear to be usable as indices into python  

Anyhow, I'm not sure if this is a python 2.5 regression, or a problem  
in all versions of python that's exposed by this behavior, or a numpy  

Any thoughts?

Test case:
In [1]: import numpy

In [2]: l = [1,2,3]

In [3]: l[numpy.argmax(l)]
<class 'exceptions.TypeError'>: list indices must be integers

In [4]: type(numpy.argmax(l))
Out[4]: <type 'int32scalar'>

In [5]: print numpy.version.version

In [6]: import sys; print sys.version
2.5a0 (trunk:42924M, Mar  8 2006, 19:29:24)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)]

More information about the Numpy-discussion mailing list