[Numpy-discussion] argmax() return type can't index python lists
Zachary Pincus
zpincus at stanford.edu
Thu Mar 9 21:34:02 CST 2006
Thanks for your reply, Travis.
> Note that the __index__ PEP I wrote was just accepted and checked-
> in so in fact *all* numpy scalar types will be acceptable as
> indices in Python2.5 (but we have to write the code for that still
> in numpy). So, it's possible that something in Python 2.5 changed
> is causing it not to work.
>
> This very-well could be a bug in the new implementation of __index__.
The problem is that I can't reproduce this bug outside of numpy. If I
go to the python people, they'll most likely say it's a numpy
problem, unless I can show some other test case. Right now, all of
the following classes work as indices in 2.5. The only thing that
doesn't work is a raw numpy.int32 value.
I'd be happy to file a bug report on python if I could figure out a
test case.
Zach
Cases which work fine:
class int_sublcass(int): pass
class empty(object): pass
class int_1(int, empty): pass
class int_2(empty, int): pass
class int_numpy_1(numpy.signedinteger, int):
def __init__(self, i):
int.__init__(self, i)
class int_numpy_2(int, numpy.signedinteger):
def __init__(self, i):
int.__init__(self, i)
l = [1,2,3]
l[int_sublcass(1)]
l[int_1(1)]
l[int_2(1)]
l[int_numpy_1(1)]
l[int_numpy_2(1)]
More information about the Numpy-discussion
mailing list