xtensor icon indicating copy to clipboard operation
xtensor copied to clipboard

Support for integer Advanced Indexing

Open tatatupi opened this issue 6 years ago • 1 comments

It seems that xtensor is lacking a part of one of the three indexing types supported numpy, the integer Advanced Indexing type.

Example for integer advanced index:

From each row, a specific element should be selected. The row index is just [0, 1, 2] and the column index specifies the element to choose for the corresponding row, here [0, 1, 0]. Using both together the task can be solved using advanced indexing:

x = np.array([[1, 2], [3, 4], [5, 6]])
x[[0, 1, 2], [0, 1, 0]]
array([1, 4, 5])

Maybe it should be included in the numpy coverage completion project?

tatatupi avatar Apr 25 '19 15:04 tatatupi

Any updates on if/when this will be implemented? It seems a few other packages (e.g. Pytorch's C++ library) can do it. In the meanwhile an example workaround would be helpful.

Rishi-V avatar Jul 15 '21 21:07 Rishi-V