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)
| 47 | |
| 48 | @array_function_dispatch(_flip_dispatcher) |
| 49 | def fliplr(m): |
| 50 | """ |
| 51 | Reverse the order of elements along axis 1 (left/right). |
| 52 | |
| 53 | For a 2-D array, this flips the entries in each row in the left/right |
| 54 | direction. Columns are preserved, but appear in a different order than |
| 55 | before. |
| 56 | |
| 57 | Parameters |
| 58 | ---------- |
| 59 | m : array_like |
| 60 | Input array, must be at least 2-D. |
| 61 | |
| 62 | Returns |
| 63 | ------- |
| 64 | f : ndarray |
| 65 | A view of `m` with the columns reversed. Since a view |
| 66 | is returned, this operation is :math:`\\mathcal O(1)`. |
| 67 | |
| 68 | See Also |
| 69 | -------- |
| 70 | flipud : Flip array in the up/down direction. |
| 71 | flip : Flip array in one or more dimensions. |
| 72 | rot90 : Rotate array counterclockwise. |
| 73 | |
| 74 | Notes |
| 75 | ----- |
| 76 | Equivalent to ``m[:,::-1]`` or ``np.flip(m, axis=1)``. |
| 77 | Requires the array to be at least 2-D. |
| 78 | |
| 79 | Examples |
| 80 | -------- |
| 81 | >>> A = np.diag([1.,2.,3.]) |
| 82 | >>> A |
| 83 | array([[1., 0., 0.], |
| 84 | [0., 2., 0.], |
| 85 | [0., 0., 3.]]) |
| 86 | >>> np.fliplr(A) |
| 87 | array([[0., 0., 1.], |
| 88 | [0., 2., 0.], |
| 89 | [3., 0., 0.]]) |
| 90 | |
| 91 | >>> A = np.random.randn(2,3,5) |
| 92 | >>> np.all(np.fliplr(A) == A[:,::-1,...]) |
| 93 | True |
| 94 | |
| 95 | """ |
| 96 | m = asanyarray(m) |
| 97 | if m.ndim < 2: |
| 98 | raise ValueError("Input must be >= 2-d.") |
| 99 | return m[:, ::-1] |
| 100 | |
| 101 | |
| 102 | @array_function_dispatch(_flip_dispatcher) |