[Numpy-discussion] numpy requires tuples for indexing where Numeric allowed them?

Travis Oliphant oliphant.travis at ieee.org
Thu Jun 7 15:16:00 EDT 2007


Jim Kleckner wrote:
> I'm fighting conversion from Numeric to numpy.
>
> One change that doesn't seem documented is that I used to be able to 
> select items using lists and now it seems that I have to convert them to 
> tuples.  Is that correct and is there a function buried in there that 
> will accept a list for indices?
>   
The problem is that with the introduction of arbitrary indexing 
(indirect indexing), lists are treated as sequences of indices instead 
of index numbers.

There is a bit of logic inserted for backward compatibility, but it 
isn't perfect.

What is the code that you are having trouble with?
> Any reason that item() can't take a list?
>   
Not that I can think of.   It could probably be updated to take a list.
> The weird thing is that it doesn't blow up right away when a list is 
> passed in an array ref but rather returns something I don't expect.
>   
Right, this is the indirect referencing feature that NumPy now supports.

-Travis




More information about the NumPy-Discussion mailing list