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

Commit

Permalink
Trac 18246: fix __hash__ in homology
Browse files Browse the repository at this point in the history
  • Loading branch information
videlec committed Aug 14, 2015
1 parent ab52a2d commit 3dfe73e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/sage/homology/cubical_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,21 @@ def __cmp__(self,other):
else:
return -1

def __hash__(self):
r"""
TESTS::
sage: I1 = cubical_complexes.Cube(1)
sage: I2 = cubical_complexes.Cube(1)
sage: hash(I1)
2025268965 # 32-bit
6535457225869567717 # 64-bit
sage: hash(I1.product(I1))
4177112485 # 32-bit
-1640877824464540251 # 64-bit
"""
return hash(frozenset(self._facets))

def is_subcomplex(self, other):
r"""
Return True if ``self`` is a subcomplex of ``other``.
Expand Down
13 changes: 13 additions & 0 deletions src/sage/homology/delta_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,19 @@ def subcomplex(self, data):
sub._is_subcomplex_of = {self: new_data}
return sub

def __hash__(self):
r"""
TESTS::
sage: hash(delta_complexes.Sphere(2))
3505125070 # 32-bit
-5090854238868998450 # 64-bit
sage: hash(delta_complexes.Sphere(4))
376965290 # 32-bit
8539734868592429226 # 64-bit
"""
return hash(frozenset(self._cells_dict.items()))

def __cmp__(self,right):
r"""
Two `\Delta`-complexes are equal, according to this, if they have
Expand Down

0 comments on commit 3dfe73e

Please sign in to comment.