From 7b751f66c7feb71646f0c2540aca2e5e67cd5db5 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Tue, 24 Mar 2009 22:25:21 +0000 Subject: Merge from the doc wiki --- numpy/lib/index_tricks.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'numpy/lib/index_tricks.py') 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]], - [[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) -- cgit v1.2.1