diff options
author | Jim Turner <git@turner.link> | 2018-12-11 14:40:14 -0500 |
---|---|---|
committer | Jim Turner <git@turner.link> | 2018-12-12 12:39:00 -0500 |
commit | 8eefc53ac9cfcd4ccc5b70ccfc900b06b389dce3 (patch) | |
tree | 969626cb6e5d0bdd7566bde9554faddf8191c48f /doc | |
parent | b40321f0668673c0519ce0e124427cb8d0cc3135 (diff) | |
download | numpy-8eefc53ac9cfcd4ccc5b70ccfc900b06b389dce3.tar.gz |
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.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/source/reference/arrays.indexing.rst | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/doc/source/reference/arrays.indexing.rst b/doc/source/reference/arrays.indexing.rst index 62d36e28c..5f67a788a 100644 --- a/doc/source/reference/arrays.indexing.rst +++ b/doc/source/reference/arrays.indexing.rst @@ -111,9 +111,10 @@ concepts to remember include: [5], [6]]]) -- :const:`Ellipsis` expand to the number of ``:`` objects needed to - make a selection tuple of the same length as ``x.ndim``. There may - only be a single ellipsis present. +- :const:`Ellipsis` expands to the number of ``:`` objects needed for the + selection tuple to index all dimensions. In most cases, this means that + length of the expanded selection tuple is ``x.ndim``. There may only be a + single ellipsis present. .. admonition:: Example |