My Understanding of [::-1] Indexing

This year I find lots of usage scenarios of this [::-1] index. And today again, when I am seeing some computer vision preprocessing program. So I want to get a deeply understand of this usage.

For 1D array

import numpy as np

# create a 1D array
arr = np.array([1, 2, 3])
print(arr[::-1])  # will print [3, 2, 1]

As the above results showing, this magic indexing will reverse the order of all elements.So, what about 2D array. let's continuing.

For 2D array

import numpy as np

# create a 2D array
arr = np.array([[1, 2, 3], [4, 5, 6]])

print(arr[::-1])
# [[4 5 6]
#  [1 2 3]]

Now I think it is clear. This magic indexing have just reversed the first dimension of matrix arr, keeping all other dimension unchanged.

Can you imagine this operation used in multi-dimensional array. For instance, a channel first , CHW, input array, it just reverse all input channel. That's it.