I have
>>> foo = np.zeros((3,3,3))
>>> foo[1,2,1] = 1
>>> idx = 1,2
I would like to get the equivalent of
>>> foo[1,2,:]
array([ 0., 1., 0.])
using idx (to iterate through idx) . Both approaches that I tried didn't work out:
>>> foo[idx, :]
array([[[ 0., 0., 0.],
[ 0., 0., 0.],
[ 0., 1., 0.]],
[[ 0., 0., 0.],
[ 0., 0., 0.],
[ 0., 0., 0.]]])
>>> foo[((idx,)+(slice(None),))]
array([[[ 0., 0., 0.],
[ 0., 0., 0.],
[ 0., 1., 0.]],
[[ 0., 0., 0.],
[ 0., 0., 0.],
[ 0., 0., 0.]]])