diff options
Diffstat (limited to 'numpy/lib/arrayterator.py')
-rw-r--r-- | numpy/lib/arrayterator.py | 29 |
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)) |