[Numpy-discussion] Getting an item in an array with its coordinates given by another array

Christian K. ckkart@hoc....
Mon Oct 29 04:50:15 CDT 2007

Matthieu Brucher <matthieu.brucher <at> gmail.com> writes:

> But if I have the coordinates of the points in an array, I have to reshape it
> and then convert it into a list. Or convert it into a list and then convert it
> to a tuple. I know that advanced indexing is useful, but here it is not
> coherent. tuples and lists should have the same result on the array, or at
> least it should be documented.

I can't give you the reasons why that behaviour was chosen. But it's simply
wrong that it's not documented. Before answering you I read the corresponding
chapter in the numpy book to be sure not to tell you nonsense. So go ahead and
do so, too.

> So there is not way to get a sub-array based on coordinates in an array?

It's just a guess, but probably you can't use an ndarray as index because
indices like this


aren't valid input for a ndarray.


More information about the Numpy-discussion mailing list