In [1]:
import numpy as np

In [2]:
a_2d = np.arange(6).reshape(2, 3)
print(a_2d)


[[0 1 2]
 [3 4 5]]

In [3]:
a_2d_flip = np.flip(a_2d)
print(a_2d_flip)


[[5 4 3]
 [2 1 0]]

In [4]:
print(np.shares_memory(a_2d, a_2d_flip))


True

In [5]:
print(a_2d[::-1, ::-1])


[[5 4 3]
 [2 1 0]]

In [6]:
a_1d = np.arange(3)
print(a_1d)


[0 1 2]

In [7]:
print(np.flip(a_1d))


[2 1 0]

In [8]:
print(a_1d[::-1])


[2 1 0]

In [9]:
a_3d = np.arange(24).reshape(2, 3, 4)
print(a_3d)


[[[ 0  1  2  3]
  [ 4  5  6  7]
  [ 8  9 10 11]]

 [[12 13 14 15]
  [16 17 18 19]
  [20 21 22 23]]]

In [10]:
print(np.flip(a_3d))


[[[23 22 21 20]
  [19 18 17 16]
  [15 14 13 12]]

 [[11 10  9  8]
  [ 7  6  5  4]
  [ 3  2  1  0]]]

In [11]:
print(a_3d[::-1, ::-1, ::-1])


[[[23 22 21 20]
  [19 18 17 16]
  [15 14 13 12]]

 [[11 10  9  8]
  [ 7  6  5  4]
  [ 3  2  1  0]]]

In [12]:
print(np.flip(a_3d, 0))


[[[12 13 14 15]
  [16 17 18 19]
  [20 21 22 23]]

 [[ 0  1  2  3]
  [ 4  5  6  7]
  [ 8  9 10 11]]]

In [13]:
print(a_3d[::-1])


[[[12 13 14 15]
  [16 17 18 19]
  [20 21 22 23]]

 [[ 0  1  2  3]
  [ 4  5  6  7]
  [ 8  9 10 11]]]

In [14]:
print(np.flipud(a_3d))


[[[12 13 14 15]
  [16 17 18 19]
  [20 21 22 23]]

 [[ 0  1  2  3]
  [ 4  5  6  7]
  [ 8  9 10 11]]]

In [15]:
print(np.flip(a_3d, 1))


[[[ 8  9 10 11]
  [ 4  5  6  7]
  [ 0  1  2  3]]

 [[20 21 22 23]
  [16 17 18 19]
  [12 13 14 15]]]

In [16]:
print(a_3d[:, ::-1])


[[[ 8  9 10 11]
  [ 4  5  6  7]
  [ 0  1  2  3]]

 [[20 21 22 23]
  [16 17 18 19]
  [12 13 14 15]]]

In [17]:
print(np.fliplr(a_3d))


[[[ 8  9 10 11]
  [ 4  5  6  7]
  [ 0  1  2  3]]

 [[20 21 22 23]
  [16 17 18 19]
  [12 13 14 15]]]

In [18]:
print(np.flip(a_3d, 2))


[[[ 3  2  1  0]
  [ 7  6  5  4]
  [11 10  9  8]]

 [[15 14 13 12]
  [19 18 17 16]
  [23 22 21 20]]]

In [19]:
print(a_3d[:, :, ::-1])


[[[ 3  2  1  0]
  [ 7  6  5  4]
  [11 10  9  8]]

 [[15 14 13 12]
  [19 18 17 16]
  [23 22 21 20]]]

In [20]:
print(np.flip(a_3d, (0, 1)))


[[[20 21 22 23]
  [16 17 18 19]
  [12 13 14 15]]

 [[ 8  9 10 11]
  [ 4  5  6  7]
  [ 0  1  2  3]]]

In [21]:
print(a_3d[::-1, ::-1])


[[[20 21 22 23]
  [16 17 18 19]
  [12 13 14 15]]

 [[ 8  9 10 11]
  [ 4  5  6  7]
  [ 0  1  2  3]]]

In [22]:
print(np.flip(a_3d, (1, 2)))


[[[11 10  9  8]
  [ 7  6  5  4]
  [ 3  2  1  0]]

 [[23 22 21 20]
  [19 18 17 16]
  [15 14 13 12]]]

In [23]:
print(a_3d[:, ::-1, ::-1])


[[[11 10  9  8]
  [ 7  6  5  4]
  [ 3  2  1  0]]

 [[23 22 21 20]
  [19 18 17 16]
  [15 14 13 12]]]

In [24]:
print(np.flip(a_3d, (0, 2)))


[[[15 14 13 12]
  [19 18 17 16]
  [23 22 21 20]]

 [[ 3  2  1  0]
  [ 7  6  5  4]
  [11 10  9  8]]]

In [25]:
print(a_3d[::-1, :, ::-1])


[[[15 14 13 12]
  [19 18 17 16]
  [23 22 21 20]]

 [[ 3  2  1  0]
  [ 7  6  5  4]
  [11 10  9  8]]]