Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-38457: Add an __iter__ to Point and Extent #42

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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