Skip to content

Commit 8eefc53

Browse files
committed
DOC: Fix desc. of Ellipsis behavior in reference
`Ellipsis` expands to make the selection tuple be consistent with the number of dimensions of the array being indexed. The length of the expanded selection tuple may not be equal to the number of dimensions in the array due to `newaxis` objects or advanced indexing. This commit fixes the docs to correctly explain the behavior of `Ellipsis`. For example, ```python >>> import numpy as np >>> x = np.zeros((3, 3, 3)) >>> x[:, ..., :2, np.newaxis].shape (3, 3, 2, 1) >>> x[:, :, :2, np.newaxis].shape (3, 3, 2, 1) ``` The `Ellipsis` expands to a single `:` so that the selection tuple can index the 3-D array. The length of the expanded selection tuple is 4, not 3 as the docs indicated before this commit.
1 parent b40321f commit 8eefc53

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

doc/source/reference/arrays.indexing.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ concepts to remember include:
111111
[5],
112112
[6]]])
113113

114-
- :const:`Ellipsis` expand to the number of ``:`` objects needed to
115-
make a selection tuple of the same length as ``x.ndim``. There may
116-
only be a single ellipsis present.
114+
- :const:`Ellipsis` expands to the number of ``:`` objects needed for the
115+
selection tuple to index all dimensions. In most cases, this means that
116+
length of the expanded selection tuple is ``x.ndim``. There may only be a
117+
single ellipsis present.
117118

118119
.. admonition:: Example
119120

0 commit comments

Comments
 (0)