How do I index a lower dimensional data array with a higher dimensional index array?
E.g.: Given a 1d data array and a 2d index array:
data = np.array([11,12,13])
idx = np.array([[0,1],
[1,2])
I would like to get a 2d data array:
np.array([[11,12],
[12,13]])
This is very easy in Python / NumPy, thanks to the advanced Numpy indexing system, you just use your indexing as the slicing, e.g.
data[idx]
.