for example:
a = np.zeros((4, 3, 2, 1))
index = (slice(0, 2, 1), 0, ...)
# a[index].shape is (2, 2, 1)
The axis 1 (second axis) of a
was collapsed.
I want to define a function that returns 1 with given a
and index
. But there are so many possibilities of index
because an index might be an int
, tuple
, list
, slice
, Ellipsis
, None
or a tuple
of them.
Is there already a function that does this in any python module? If not, what is the best approach to make it?
Thanks!