I was learning boolean indexing in numpy and came across this. How is the indexing below not producing a Index Error as for axis 0 as there are only two blocks?
x = np.arange(30).reshape(2, 3, 5)
x
array([[[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14]],
[[15, 16, 17, 18, 19],
[20, 21, 22, 23, 24],
[25, 26, 27, 28, 29]]])
x[[[True, True, False], [False, True, True]]]
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[20, 21, 22, 23, 24],
[25, 26, 27, 28, 29]])
np.nonzero(...)to see the equivalent advanced indexing arrays, e.g.(array([0, 0, 1, 1]), array([0, 1, 1, 2])). So the equivalent operation isx[[0,0,1,1], [0,1,1,2], :]