summaryrefslogtreecommitdiff
path: root/doc/source/reference/arrays.indexing.rst
diff options
context:
space:
mode:
Diffstat (limited to 'doc/source/reference/arrays.indexing.rst')
-rw-r--r--doc/source/reference/arrays.indexing.rst34
1 files changed, 23 insertions, 11 deletions
diff --git a/doc/source/reference/arrays.indexing.rst b/doc/source/reference/arrays.indexing.rst
index 62d36e28c..8ec8d8330 100644
--- a/doc/source/reference/arrays.indexing.rst
+++ b/doc/source/reference/arrays.indexing.rst
@@ -3,6 +3,10 @@
Indexing
========
+.. seealso::
+
+ :ref:`Indexing basics <basics.indexing>`
+
.. sectionauthor:: adapted from "Guide to NumPy" by Travis E. Oliphant
.. currentmodule:: numpy
@@ -57,6 +61,17 @@ interpreted as counting from the end of the array (*i.e.*, if
All arrays generated by basic slicing are always :term:`views <view>`
of the original array.
+.. note::
+
+ NumPy slicing creates a :term:`view` instead of a copy as in the case of
+ builtin Python sequences such as string, tuple and list.
+ Care must be taken when extracting
+ a small portion from a large array which becomes useless after the
+ extraction, because the small portion extracted contains a reference
+ to the large original array whose memory will not be released until
+ all arrays derived from it are garbage-collected. In such cases an
+ explicit ``copy()`` is recommended.
+
The standard rules of sequence slicing apply to basic slicing on a
per-dimension basis (including using a step index). Some useful
concepts to remember include:
@@ -111,9 +126,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
@@ -513,14 +529,10 @@ only the part of the data in the specified field. Also
:ref:`record array <arrays.classes.rec>` scalars can be "indexed" this way.
Indexing into a structured array can also be done with a list of field names,
-*e.g.* ``x[['field-name1','field-name2']]``. Currently this returns a new
-array containing a copy of the values in the fields specified in the list.
-As of NumPy 1.7, returning a copy is being deprecated in favor of returning
-a view. A copy will continue to be returned for now, but a FutureWarning
-will be issued when writing to the copy. If you depend on the current
-behavior, then we suggest copying the returned array explicitly, i.e. use
-x[['field-name1','field-name2']].copy(). This will work with both past and
-future versions of NumPy.
+*e.g.* ``x[['field-name1','field-name2']]``. As of NumPy 1.16 this returns a
+view containing only those fields. In older versions of numpy it returned a
+copy. See the user guide section on :ref:`structured_arrays` for more
+information on multifield indexing.
If the accessed field is a sub-array, the dimensions of the sub-array
are appended to the shape of the result.