Skip to content

Commit d5ec898

Browse files
author
Release Manager
committed
gh-40456: __iter__ method for the AffineGroup class Fixes #40412. If it is possible to iterate over a vector space and the corresponding general linear group, then it should also be possible to iterate over the associated affine group. So we add an `__iter__` method to the `AffineGroup` class (and also a `__len__` method). ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #40456 Reported by: DaveWitteMorris Reviewer(s):
2 parents 103656e + 1d2a767 commit d5ec898

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/sage/groups/affine_gps/affine_group.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,3 +532,17 @@ def some_elements(self):
532532
vecs = self.vector_space().some_elements()
533533
return [self.element_class(self, A, b, check=False, convert=False)
534534
for A in mats for b in vecs]
535+
536+
def __iter__(self):
537+
"""
538+
TESTS::
539+
540+
sage: G = AffineGroup(2, 3)
541+
sage: len([g for g in G]) == G.cardinality() # indirect doctest
542+
True
543+
"""
544+
for A in self._GL:
545+
for b in self.vector_space():
546+
yield self.element_class(self, A, b, check=False, convert=False)
547+
548+
__len__ = cardinality

0 commit comments

Comments
 (0)