[Numpy-discussion] Logical indexing and higher-dimensional arrays.
Sturla Molden
sturla at molden.no
Wed Feb 8 10:08:29 EST 2012
On 08.02.2012 15:11, Olivier Delalleau wrote:
> From a user perspective, I would definitely prefer cross-product
> semantics for fancy indexing. In fact, I had never used fancy indexing
> with more than one array index, so the behavior described in this thread
> totally baffled me. If for instance x is a matrix, I think it's
> intuitive to expect x[0:2, 0:2] and x[[0, 1], [0, 1]] to return the same
> data.
I think most would prefer cross-product semantics. We might be copying a
bad feature of Matlab. Maybe we should just disallow fancy indexing with
more than one dimension, e.g. array[X,Y] with X and Y from meshgrid. It
might be that the kind of result x[[0, 1],[0, 1]] produces today is
better left to a function, e.g. np.meshselect(x, *indices). Then we
could just require that all arguments passed to *indices have the same
shape.
Sturla
More information about the NumPy-Discussion
mailing list