[Numpy-discussion] Inconsistent/unexpected indexing semantics
vilanova at ac.upc.edu
Mon Nov 30 12:42:06 EST 2015
TL;DR: There's a pending pull request deprecating some behaviour I find
unexpected. Does anyone object?
Some time ago I noticed that numpy yields unexpected results in some very
specific cases. An array can be used to index multiple elements of a single
>>> a = np.arange(8).reshape((2,2,2))
>>> a[ np.array([, ]) ]
Nonetheless, if a list is used instead, it is (unexpectedly) transformed into a
tuple, resulting in indexing across multiple dimensions:
>>> a[ [, ] ]
I.e., it is interpeted as:
>>> a[ ,  ]
Or what is the same:
>>> a[( ,  )]
I've been informed that there's a pending pull request that deprecates this
behaviour , which could in the future be reverted to what is expected (at
least what I expect) from the documents (except for an obscure note in ).
The discussion leading to this mail can be found here .
"And it's much the same thing with knowledge, for whenever you learn
something new, the whole world becomes that much richer."
-- The Princess of Pure Reason, as told by Norton Juster in The Phantom
More information about the NumPy-Discussion