Skip to content

Commit

Permalink
Merge pull request #42 from lsst/tickets/DM-38457
Browse files Browse the repository at this point in the history
DM-38457: Add an __iter__ to Point and Extent
  • Loading branch information
timj committed Mar 29, 2023
2 parents f0d0fc7 + b499ae1 commit 3f8e190
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/lsst/geom/_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ def _coordinateReduce(self):
return (type(self), tuple(self))


def _coordinateIter(self):
for i in range(self.dimensions):
yield self[i]


class CoordinateExpr(metaclass=TemplateMeta):
"""Abstract base class and factory for CoordinateExpr objects.
"""
Expand All @@ -50,6 +55,7 @@ class CoordinateExpr(metaclass=TemplateMeta):
__str__ = _coordinateStr
__repr__ = _coordinateRepr
__reduce__ = _coordinateReduce
__iter__ = _coordinateIter


CoordinateExpr.register(2, _geom.CoordinateExpr2)
Expand All @@ -65,6 +71,7 @@ class Extent(metaclass=TemplateMeta):
__str__ = _coordinateStr
__repr__ = _coordinateRepr
__reduce__ = _coordinateReduce
__iter__ = _coordinateIter


Extent.register((int, 2), _geom.Extent2I)
Expand All @@ -84,6 +91,7 @@ class Point(metaclass=TemplateMeta):
__str__ = _coordinateStr
__repr__ = _coordinateRepr
__reduce__ = _coordinateReduce
__iter__ = _coordinateIter


Point.register((int, 2), _geom.Point2I)
Expand Down

0 comments on commit 3f8e190

Please sign in to comment.