From 4ca2465fe169576b46dee783dd0279cfd536d9c4 Mon Sep 17 00:00:00 2001 From: rgommers Date: Wed, 2 Mar 2011 12:43:47 +0800 Subject: DOC: merge more doc wiki edits. --- numpy/lib/arrayterator.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'numpy/lib/arrayterator.py') diff --git a/numpy/lib/arrayterator.py b/numpy/lib/arrayterator.py index 3f07cd263..2df05e514 100644 --- a/numpy/lib/arrayterator.py +++ b/numpy/lib/arrayterator.py @@ -141,12 +141,41 @@ class Arrayterator(object): @property def flat(self): + """ + A 1-D flat iterator for Arrayterator objects. + + This iterator returns elements of the array to be iterated over in + `Arrayterator` one by one. It is similar to `flatiter`. + + See Also + -------- + `Arrayterator` + flatiter + + Examples + -------- + >>> a = np.arange(3 * 4 * 5 * 6).reshape(3, 4, 5, 6) + >>> a_itor = np.lib.arrayterator.Arrayterator(a, 2) + + >>> for subarr in a_itor.flat: + ... if not subarr: + ... print subarr, type(subarr) + ... + 0 + + """ for block in self: for value in block.flat: yield value @property def shape(self): + """ + The shape of the array to be iterated over. + + For an example, see `Arrayterator`. + + """ return tuple(((stop-start-1)//step+1) for start, stop, step in zip(self.start, self.stop, self.step)) -- cgit v1.2.1