summaryrefslogtreecommitdiff
path: root/doc/source/user
diff options
context:
space:
mode:
authorPieter <pmvz_github@outlook.com>2023-02-10 18:19:39 +0100
committerGitHub <noreply@github.com>2023-02-10 18:19:39 +0100
commit96e07907e3bb44afd46187d4e4b2c16745b24299 (patch)
tree0d69cd27e9fc8ff2aecd5ebdbb7cf6a8a2d4577a /doc/source/user
parentbaa84cfa9c0b68d9d540be749da77a7c9928980e (diff)
downloadnumpy-96e07907e3bb44afd46187d4e4b2c16745b24299.tar.gz
DOC: Limit line lengths
Diffstat (limited to 'doc/source/user')
-rw-r--r--doc/source/user/how-to-index.rst10
1 files changed, 8 insertions, 2 deletions
diff --git a/doc/source/user/how-to-index.rst b/doc/source/user/how-to-index.rst
index 02db91670..97c451260 100644
--- a/doc/source/user/how-to-index.rst
+++ b/doc/source/user/how-to-index.rst
@@ -310,7 +310,11 @@ result as dimensions with size one::
<BLANKLINE>
[[2, 2, 2, 2, 2]]])
-To get the indices of each maximum or minimum value for each (N-1)-dimensional array in an N-dimensional array, use :meth:`reshape` to reshape the array to a 2D array, apply :meth:`argmax` or :meth:`argmin` along ``axis=1`` and use :meth:`unravel_index` to recover the index of the values per slice::
+To get the indices of each maximum or minimum value for each
+(N-1)-dimensional array in an N-dimensional array, use :meth:`reshape`
+to reshape the array to a 2D array, apply :meth:`argmax` or :meth:`argmin`
+along ``axis=1`` and use :meth:`unravel_index` to recover the index of the
+values per slice::
>>> x = np.arange(2*2*3).reshape(2, 2, 3) % 7 # 3D example array
>>> x
@@ -326,7 +330,9 @@ To get the indices of each maximum or minimum value for each (N-1)-dimensional a
>>> np.unravel_index(indices_2d, x.shape[1:])
(array([1, 0]), array([2, 0]))
-The first array returned contains the indices along axis 1 in the original array, the second array contains the indices along axis 2. The highest value in ``x[0]`` is therefore ``x[0, 1, 2]``.
+The first array returned contains the indices along axis 1 in the original
+array, the second array contains the indices along axis 2. The highest
+value in ``x[0]`` is therefore ``x[0, 1, 2]``.
Index the same ndarray multiple times efficiently
=================================================