From 8eefc53ac9cfcd4ccc5b70ccfc900b06b389dce3 Mon Sep 17 00:00:00 2001 From: Jim Turner Date: Tue, 11 Dec 2018 14:40:14 -0500 Subject: 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. --- doc/source/reference/arrays.indexing.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'doc/source/reference') 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 -- cgit v1.2.1