Skip to content

Commit 0789383

Browse files
committed
Add __iter__() method
1 parent 5c9f855 commit 0789383

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

dpnp/dpnp_array.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,11 @@ def __isub__(self, other):
434434
dpnp.subtract(self, other, out=self)
435435
return self
436436

437-
# '__iter__',
437+
def __iter__(self):
438+
"""Return ``iter(self)``."""
439+
if self.ndim == 0:
440+
raise TypeError("iteration over a 0-d array")
441+
return (self[i] for i in range(self.shape[0]))
438442

439443
def __itruediv__(self, other):
440444
"""Return ``self/=value``."""

0 commit comments

Comments
 (0)