MCPcopy Create free account
hub / github.com/numpy/numpy / flipud

Function flipud

numpy/lib/twodim_base.py:103–155  ·  view source on GitHub ↗

Reverse the order of elements along axis 0 (up/down). For a 2-D array, this flips the entries in each column in the up/down direction. Rows are preserved, but appear in a different order than before. Parameters ---------- m : array_like Input array. Returns

(m)

Source from the content-addressed store, hash-verified

101
102@array_function_dispatch(_flip_dispatcher)
103def flipud(m):
104 """
105 Reverse the order of elements along axis 0 (up/down).
106
107 For a 2-D array, this flips the entries in each column in the up/down
108 direction. Rows are preserved, but appear in a different order than before.
109
110 Parameters
111 ----------
112 m : array_like
113 Input array.
114
115 Returns
116 -------
117 out : array_like
118 A view of `m` with the rows reversed. Since a view is
119 returned, this operation is :math:`\\mathcal O(1)`.
120
121 See Also
122 --------
123 fliplr : Flip array in the left/right direction.
124 flip : Flip array in one or more dimensions.
125 rot90 : Rotate array counterclockwise.
126
127 Notes
128 -----
129 Equivalent to ``m[::-1, ...]`` or ``np.flip(m, axis=0)``.
130 Requires the array to be at least 1-D.
131
132 Examples
133 --------
134 >>> A = np.diag([1.0, 2, 3])
135 >>> A
136 array([[1., 0., 0.],
137 [0., 2., 0.],
138 [0., 0., 3.]])
139 >>> np.flipud(A)
140 array([[0., 0., 3.],
141 [0., 2., 0.],
142 [1., 0., 0.]])
143
144 >>> A = np.random.randn(2,3,5)
145 >>> np.all(np.flipud(A) == A[::-1,...])
146 True
147
148 >>> np.flipud([1,2])
149 array([2, 1])
150
151 """
152 m = asanyarray(m)
153 if m.ndim < 1:
154 raise ValueError("Input must be >= 1-d.")
155 return m[::-1, ...]
156
157
158@set_array_function_like_doc

Callers 7

test_hanningMethod · 0.90
test_hammingMethod · 0.90
test_bartlettMethod · 0.90
test_blackmanMethod · 0.90
test_kaiserMethod · 0.90
test_simpleMethod · 0.90
test_basicMethod · 0.90

Calls 1

asanyarrayFunction · 0.85

Tested by 7

test_hanningMethod · 0.72
test_hammingMethod · 0.72
test_bartlettMethod · 0.72
test_blackmanMethod · 0.72
test_kaiserMethod · 0.72
test_simpleMethod · 0.72
test_basicMethod · 0.72