Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
py3: hash for Cartesian product elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Chapoton committed Aug 31, 2018
1 parent 8b4f9a0 commit bc571fd
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/sage/structure/element_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,8 @@ class ElementWrapperTester(ElementWrapper):
sage: x.value = [2,32]; x # indirect doctest
[n=0, value=[2, 32]]
"""
return "[n=%s, value=%s]"%(self.n, self.value)
return "[n=%s, value=%s]" % (self.n, self.value)


cdef class ElementWrapperCheckWrappedClass(ElementWrapper):
"""
Expand All @@ -518,6 +519,23 @@ cdef class ElementWrapperCheckWrappedClass(ElementWrapper):
"""
wrapped_class = object

def __hash__(self):
"""
Return the same hash as for the wrapped element.
EXAMPLES::
sage: A = cartesian_product([ZZ, ZZ])
sage: e1 = A((6,9))
sage: e2 = A((3,8))
sage: e3 = A((6,9))
sage: hash(e1) == hash(e2)
False
sage: hash(e1) == hash(e3)
True
"""
return hash(self.value)

def __richcmp__(left, right, int op):
"""
Return ``True`` if ``left`` compares with ``right`` based on ``op``.
Expand Down

0 comments on commit bc571fd

Please sign in to comment.