Skip to content

Commit

Permalink
Trac #34188: provide hash for decorated permutations
Browse files Browse the repository at this point in the history
Provide a hash function for decorated permutations.

URL: https://trac.sagemath.org/34188
Reported by: mantepse
Ticket author(s): Martin Rubey
Reviewer(s): Vincent Delecroix
  • Loading branch information
Release Manager committed Aug 28, 2022
2 parents 6f0dbf9 + 0b343bd commit e96e201
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/sage/combinat/decorated_permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ def check(self):
if self not in self.parent():
raise ValueError("{} is not a decorated permutation".format(self))

def __hash__(self):
r"""
Return a hash of ``self``.
TESTS::
sage: len(set(hash(pi) for pi in DecoratedPermutations(3)))
16
"""
return hash(tuple(self))

def __eq__(self, other):
"""
Check whether ``self`` is equal to ``other``.
Expand Down

0 comments on commit e96e201

Please sign in to comment.