summaryrefslogtreecommitdiff
path: root/numpy/lib/index_tricks.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/index_tricks.py')
-rw-r--r--numpy/lib/index_tricks.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py
index fcd3909af..b8add9ed7 100644
--- a/numpy/lib/index_tricks.py
+++ b/numpy/lib/index_tricks.py
@@ -34,7 +34,7 @@ def unravel_index(x,dims):
Examples
--------
- >>> arr = np.ones((5,4))
+ >>> arr = np.arange(20).reshape(5,4)
>>> arr
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
@@ -130,7 +130,6 @@ class nd_grid(object):
[2, 2, 2, 2, 2],
[3, 3, 3, 3, 3],
[4, 4, 4, 4, 4]],
- <BLANKLINE>
[[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
@@ -396,11 +395,20 @@ class ndenumerate(object):
class ndindex(object):
- """Pass in a sequence of integers corresponding
- to the number of dimensions in the counter. This iterator
- will then return an N-dimensional counter.
+ """
+ An N-dimensional iterator object to index arrays.
+
+ Given the shape of an array, an `ndindex` instance iterates over
+ the N-dimensional index of the array. At each iteration, the index of the
+ last dimension is incremented by one.
- Example:
+ Parameters
+ ----------
+ `*args` : integers
+ The size of each dimension in the counter.
+
+ Examples
+ --------
>>> for index in np.ndindex(3,2,1):
... print index
(0, 0, 0)