Skip to content

Commit

Permalink
fix bug with generating random elements of SmallGroup(1,1)
Browse files Browse the repository at this point in the history
  • Loading branch information
perlinm committed Aug 20, 2024
1 parent c0b176d commit d665cee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions qldpc/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,10 @@ def __init__(self, order: int, index: int) -> None:
super()._init_from_group(Group.from_name(name))
self.index = index

def random(self, *, seed: int | None = None) -> GroupMember:
"""A random element this group."""
return super().random(seed=seed) if self.index > 1 else self.identity

@functools.cached_property
def structure(self) -> str:
"""A description of the structure of this group."""
Expand Down
4 changes: 3 additions & 1 deletion qldpc/abstract_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,6 @@ def test_small_group() -> None:
assert group.structure == structure

# cover a special case
assert abstract.Group.from_name("SmallGroup(1,1)") == abstract.TrivialGroup()
group = abstract.SmallGroup(1, 1)
assert group == abstract.TrivialGroup()
assert group.random() == group.identity

0 comments on commit d665cee

Please sign in to comment.