MCPcopy Index your code
hub / github.com/numpy/numpy / fliplr

Function fliplr

numpy/lib/_twodim_base_impl.py:65–117  ·  view source on GitHub ↗

Reverse the order of elements along axis 1 (left/right). For a 2-D array, this flips the entries in each row in the left/right direction. Columns are preserved, but appear in a different order than before. Parameters ---------- m : array_like Input array, must

(m)

Source from the content-addressed store, hash-verified

63
64@array_function_dispatch(_flip_dispatcher)
65def fliplr(m):
66 """
67 Reverse the order of elements along axis 1 (left/right).
68
69 For a 2-D array, this flips the entries in each row in the left/right
70 direction. Columns are preserved, but appear in a different order than
71 before.
72
73 Parameters
74 ----------
75 m : array_like
76 Input array, must be at least 2-D.
77
78 Returns
79 -------
80 f : ndarray
81 A view of `m` with the columns reversed. Since a view
82 is returned, this operation is :math:`\\mathcal O(1)`.
83
84 See Also
85 --------
86 flipud : Flip array in the up/down direction.
87 flip : Flip array in one or more dimensions.
88 rot90 : Rotate array counterclockwise.
89
90 Notes
91 -----
92 Equivalent to ``m[:,::-1]`` or ``np.flip(m, axis=1)``.
93 Requires the array to be at least 2-D.
94
95 Examples
96 --------
97 >>> import numpy as np
98 >>> A = np.diag([1.,2.,3.])
99 >>> A
100 array([[1., 0., 0.],
101 [0., 2., 0.],
102 [0., 0., 3.]])
103 >>> np.fliplr(A)
104 array([[0., 0., 1.],
105 [0., 2., 0.],
106 [3., 0., 0.]])
107
108 >>> rng = np.random.default_rng()
109 >>> A = rng.normal(size=(2,3,5))
110 >>> np.all(np.fliplr(A) == A[:,::-1,...])
111 True
112
113 """
114 m = asanyarray(m)
115 if m.ndim < 2:
116 raise ValueError("Input must be >= 2-d.")
117 return m[:, ::-1]
118
119
120@array_function_dispatch(_flip_dispatcher)

Callers 1

test_basicMethod · 0.90

Calls 1

asanyarrayFunction · 0.85

Tested by 1

test_basicMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…