summaryrefslogtreecommitdiff
path: root/numpy/lib/arrayterator.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/arrayterator.py')
-rw-r--r--numpy/lib/arrayterator.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/numpy/lib/arrayterator.py b/numpy/lib/arrayterator.py
index d9839feeb..fb52ada86 100644
--- a/numpy/lib/arrayterator.py
+++ b/numpy/lib/arrayterator.py
@@ -69,9 +69,8 @@ class Arrayterator(object):
Examples
--------
- >>> import numpy as np
>>> a = np.arange(3 * 4 * 5 * 6).reshape(3, 4, 5, 6)
- >>> a_itor = np.lib.arrayterator.Arrayterator(a, 2)
+ >>> a_itor = np.lib.Arrayterator(a, 2)
>>> a_itor.shape
(3, 4, 5, 6)
@@ -81,7 +80,7 @@ class Arrayterator(object):
>>> for subarr in a_itor:
... if not subarr.all():
- ... print subarr, subarr.shape
+ ... print(subarr, subarr.shape)
...
[[[[0 1]]]] (1, 1, 1, 2)
@@ -149,17 +148,17 @@ class Arrayterator(object):
See Also
--------
- `Arrayterator`
+ Arrayterator
flatiter
Examples
--------
>>> a = np.arange(3 * 4 * 5 * 6).reshape(3, 4, 5, 6)
- >>> a_itor = np.lib.arrayterator.Arrayterator(a, 2)
+ >>> a_itor = np.lib.Arrayterator(a, 2)
>>> for subarr in a_itor.flat:
... if not subarr:
- ... print subarr, type(subarr)
+ ... print(subarr, type(subarr))
...
0 <type 'numpy.int32'>
@@ -182,7 +181,7 @@ class Arrayterator(object):
def __iter__(self):
# Skip arrays with degenerate dimensions
if [dim for dim in self.shape if dim <= 0]:
- raise StopIteration
+ return
start = self.start[:]
stop = self.stop[:]
@@ -223,4 +222,4 @@ class Arrayterator(object):
start[i] = self.start[i]
start[i-1] += self.step[i-1]
if start[0] >= self.stop[0]:
- raise StopIteration
+ return