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

Commit 83dcbb1

Browse files
committed
Add __hash__ to ContinousMap
1 parent 177aa8e commit 83dcbb1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/sage/manifolds/continuous_map.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,32 @@ def _latex_(self):
514514
else:
515515
return self._latex_name
516516

517+
#
518+
# Hash and equality
519+
#
520+
521+
def __hash__(self):
522+
"""
523+
Hash function.
524+
525+
TESTS::
526+
527+
sage: M = Manifold(2, 'M', structure='topological')
528+
sage: X.<x,y> = M.chart()
529+
sage: N = Manifold(2, 'N', structure='topological')
530+
sage: Y.<u,v> = N.chart()
531+
sage: f = M.continuous_map(N, {(X,Y): (x+y,x*y)})
532+
sage: hash(f) == f.__hash__()
533+
True
534+
535+
Let us check that ``f`` can be used as a dictionary key::
536+
537+
sage: {f: 1}[f]
538+
1
539+
540+
"""
541+
return hash((self._domain, self._codomain))
542+
517543
def __eq__(self, other):
518544
r"""
519545
Comparison (equality) operator.

0 commit comments

Comments
 (0)