Skip to content

DOC: Rearranged parts of the Indexing docs to consolidate content #19407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
DOC: Replaced indexing stub doc with routines
  • Loading branch information
Mukulikaa committed Aug 18, 2021
commit a3c72d61587e5896f39c86d4696a7cd449c3ca7b
122 changes: 66 additions & 56 deletions doc/source/reference/arrays.indexing.rst
Original file line number Diff line number Diff line change
@@ -1,60 +1,70 @@
.. for doctests
>>> import numpy as np

.. _routines.indexing:
.. _arrays.indexing:

********
Indexing
********

.. seealso::

:ref:`basics.indexing`

:ref:`Indexing routines <routines.indexing>`

Array indexing refers to any use of the square brackets ([]) to index
array values. There are many options to indexing, which give NumPy
indexing great power, but with power comes some complexity and the
potential for confusion. This section is just an overview of the
various options and issues related to indexing. Further details can be
found in the relevant sections of :ref:`basics.indexing`.


Basic indexing
==============

Basic indexing will be triggered through single element indexing or
slicing and striding.

Single element indexing works
exactly like that for other standard Python sequences but has been expanded
to support multidimensional indexing
for multidimensional NumPy arrays. For more details and examples, see
:ref:`single-element-indexing`.

It is possible to slice and stride arrays to extract arrays of the
same number of dimensions, but of different sizes than the original.
The slicing and striding work exactly the same way it does for lists
and tuples except that they can be applied to multiple dimensions as
well. See :ref:`basic-slicing-and-indexing` for more information and examples.


Advanced indexing
Indexing routines
=================

Arrays can be indexed with other arrays to
select lists of values out of arrays into new arrays. There are
two different ways of accomplishing this. One uses one or more arrays
of index values. The other involves giving a boolean array of the proper
shape to indicate the values to be selected. Index arrays are a very
powerful tool that allows one to avoid looping over individual elements in
arrays and thus greatly improve performance. See :ref:`advanced-indexing`
for more information and examples.


Other indexing options
======================

:ref:`arrays.indexing.fields`, :ref:`flat-iterator-indexing` are a couple
of other indexing options.
.. seealso:: :ref:`basics.indexing`

.. currentmodule:: numpy

Generating index arrays
-----------------------
.. autosummary::
:toctree: generated/

c_
r_
s_
nonzero
where
indices
ix_
ogrid
ravel_multi_index
unravel_index
diag_indices
diag_indices_from
mask_indices
tril_indices
tril_indices_from
triu_indices
triu_indices_from

Indexing-like operations
------------------------
.. autosummary::
:toctree: generated/

take
take_along_axis
choose
compress
diag
diagonal
select
lib.stride_tricks.sliding_window_view
lib.stride_tricks.as_strided

Inserting data into arrays
--------------------------
.. autosummary::
:toctree: generated/

place
put
put_along_axis
putmask
fill_diagonal

Iterating over arrays
---------------------
.. autosummary::
:toctree: generated/

nditer
ndenumerate
ndindex
nested_iters
flatiter
lib.Arrayterator
69 changes: 0 additions & 69 deletions doc/source/reference/routines.indexing.rst

This file was deleted.

1 change: 0 additions & 1 deletion doc/source/reference/routines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ indentation.
routines.fft
routines.functional
routines.help
routines.indexing
routines.io
routines.linalg
routines.logic
Expand Down
8 changes: 3 additions & 5 deletions doc/source/user/basics.indexing.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
.. _basics.indexing:

***************
Indexing basics
***************
****************************************
Indexing on :class:`ndarrays <.ndarray>`
****************************************

.. seealso::

:ref:`arrays.indexing`

:ref:`Indexing routines <routines.indexing>`

.. sectionauthor:: adapted from "Guide to NumPy" by Travis E. Oliphant
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy