I need to be able to return a part of a multidimensional array, but I don't know how to do this in a correct way. The way I do it seems very naive:
import numpy as np
a=np.ones([3,3,3,3,3])
b=np.asarray([2,2])
c=np.asarray([2,2])
print a[b[0],b[1],:,c[0],c[1]]
and will return
[1,1,1]
However what I want is something like this:
a=np.ones([3,3,3,3,3])
b=np.asarray([2,2])
c=np.asarray([2,2])
print a[b,:,c]
Which returns the a
itself, Although I want it to return [1,1,1]
instead.
And I don't know why. How can I read part of an array without specifying element by element but giving the indices of the array I want as a pack?
P.S. Thanks to @hcwhsa, I updated the question to address more specifically what I want.