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

fix hash of PermutationGroup_generic #38871

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/sage/groups/perm_gps/permgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,22 @@ def _magma_init_(self, magma):
g = ', '.join([g._gap_cycle_string() for g in self.gens()])
return 'PermutationGroup<%s | %s>' % (self.degree(), g)

def __hash__(self):
r"""
Return a hash value for ``self``.

TESTS::

sage: G = PermutationGroup([(1,2,3), (1,3)])
sage: G == SymmetricGroup(3)
True
sage: G.gens() == SymmetricGroup(3).gens()
False
sage: G in set([SymmetricGroup(3)])
True
"""
return hash(self.cardinality())

def __richcmp__(self, right, op):
"""
Compare ``self`` and ``right``.
Expand Down
12 changes: 3 additions & 9 deletions src/sage/groups/perm_gps/permgroup_named.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,15 @@

class PermutationGroup_unique(CachedRepresentation, PermutationGroup_generic):
"""
.. TODO::

Fix the broken hash. ::

sage: G = SymmetricGroup(6)
sage: G3 = G.subgroup([G((1,2,3,4,5,6)),G((1,2))])
sage: hash(G) == hash(G3) # todo: Should be True!
False

TESTS::

sage: G = SymmetricGroup(6)
sage: G3 = G.subgroup([G((1,2,3,4,5,6)),G((1,2))])
sage: G == G3
True

sage: hash(G) == hash(G3)
True
"""
@weak_cached_function
def __classcall__(cls, *args, **kwds):
Expand Down Expand Up @@ -3513,7 +3507,7 @@
[ 2 0 -1 -2 0 1]
[ 2 0 -1 2 0 -1]
sage: def numgps(n): return ZZ(libgap.NumberSmallGroups(n))
sage: all(SmallPermutationGroup(n,k).id() == [n,k]

Check warning on line 3510 in src/sage/groups/perm_gps/permgroup_named.py

View workflow job for this annotation

GitHub Actions / test-new

Warning: slow doctest:

slow doctest:

Check warning on line 3510 in src/sage/groups/perm_gps/permgroup_named.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:
....: for n in [1..64] for k in [1..numgps(n)])
True
sage: H = SmallPermutationGroup(6,1)
Expand Down
Loading