summaryrefslogtreecommitdiff
path: root/numpy/lib/arrayterator.py
diff options
context:
space:
mode:
authorrgommers <ralf.gommers@googlemail.com>2011-03-02 12:43:47 +0800
committerrgommers <ralf.gommers@googlemail.com>2011-03-02 13:23:48 +0800
commit4ca2465fe169576b46dee783dd0279cfd536d9c4 (patch)
treed682c1b79e51bb52dd5493337facf2afc5dbca76 /numpy/lib/arrayterator.py
parent7ef5d601b4fe281c797fa497c317861c7340e3ec (diff)
downloadnumpy-4ca2465fe169576b46dee783dd0279cfd536d9c4.tar.gz
DOC: merge more doc wiki edits.
Diffstat (limited to 'numpy/lib/arrayterator.py')
-rw-r--r--numpy/lib/arrayterator.py29
1 files changed, 29 insertions, 0 deletions
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 <type 'numpy.int32'>
+
+ """
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))