summaryrefslogtreecommitdiff
path: root/numpy/lib/index_tricks.py
diff options
context:
space:
mode:
authorNeal C <nealchau@gmail.com>2020-07-11 12:34:18 -0700
committerGitHub <noreply@github.com>2020-07-11 22:34:18 +0300
commit0c8f0f96042bcc97d3d3ebf81b0eb0757623463b (patch)
treeab1a690a883e9c3c82e08d8e8f28b0afc3be21dc /numpy/lib/index_tricks.py
parent4a54bc458b93adbea75cb3ba05978ab327ff1552 (diff)
downloadnumpy-0c8f0f96042bcc97d3d3ebf81b0eb0757623463b.tar.gz
DOC: adding docs on passing dimensions as tuple to ndindex (#16806)
* adding documentation on passing dimensions to ndindex as a tuple Co-authored-by: sun <sun@vosdbt.org>
Diffstat (limited to 'numpy/lib/index_tricks.py')
-rw-r--r--numpy/lib/index_tricks.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py
index d528b3e10..e86c7a7bb 100644
--- a/numpy/lib/index_tricks.py
+++ b/numpy/lib/index_tricks.py
@@ -611,8 +611,9 @@ class ndindex:
Parameters
----------
- `*args` : ints
- The size of each dimension of the array.
+ `*args` : ints, or a single tuple of ints
+ The size of each dimension of the array can be passed as
+ individual parameters or as the elements of a tuple.
See Also
--------
@@ -620,6 +621,7 @@ class ndindex:
Examples
--------
+ # dimensions as individual arguments
>>> for index in np.ndindex(3, 2, 1):
... print(index)
(0, 0, 0)
@@ -629,6 +631,16 @@ class ndindex:
(2, 0, 0)
(2, 1, 0)
+ # same dimensions - but in a tuple (3, 2, 1)
+ >>> for index in np.ndindex((3, 2, 1)):
+ ... print(index)
+ (0, 0, 0)
+ (0, 1, 0)
+ (1, 0, 0)
+ (1, 1, 0)
+ (2, 0, 0)
+ (2, 1, 0)
+
"""
def __init__(self, *shape):