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

Commit

Permalink
Trac #30266: remove dependency of #30116
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Jung committed Aug 4, 2020
1 parent a5f6a19 commit 37b0042
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/sage/manifolds/scalarfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -2144,8 +2144,7 @@ def restrict(self, subdomain):
resu = type(self)(subdomain.scalar_field_algebra(),
coord_expression=sexpress, name=self._name,
latex_name=self._latex_name)
if self.is_immutable():
resu.set_immutable() # restriction must be immutable, too
resu.set_immutable() # restriction must be immutable, too
self._restrictions[subdomain] = resu
return self._restrictions[subdomain]

Expand Down Expand Up @@ -3490,14 +3489,17 @@ def set_immutable(self):
sage: M = Manifold(2, 'M')
sage: X.<x,y> = M.chart()
sage: U = M.open_subset('U', coord_def={X: x^2+y^2<1})
sage: U = M.open_subset('U', coord_def={X: x^2+y^2<1}) # disk
sage: V = M.open_subset('V', coord_def={X: x>0}) # half plane
sage: f = M.scalar_field(x^2, name='f')
sage: fU = f.restrict(U)
sage: f.set_immutable()
sage: f.is_immutable()
True
sage: fU = f.restrict(U)
sage: fU.is_immutable()
True
sage: f.restrict(V).is_immutable()
True
"""
for rst in self._restrictions.values():
Expand All @@ -3515,16 +3517,14 @@ def __hash__(self):
sage: X.<x,y> = M.chart()
sage: U = M.open_subset('U', coord_def={X: x^2+y^2<1})
sage: f = M.scalar_field(x^2, name='f')
sage: fU = f.restrict(U)
sage: f.set_immutable()
sage: fU.is_immutable()
True
sage: g = M.scalar_field(x^2, name='g')
sage: f.set_immutable(); g.set_immutable()
Check whether equality on common domain implies equality of hash::
Check whether equality of scalar fields implies equality of hash::
sage: f == fU
sage: f == g
True
sage: hash(f) == hash(fU)
sage: hash(f) == hash(g)
True
Let us check that ``f`` can be used as a dictionary key::
Expand All @@ -3536,5 +3536,4 @@ def __hash__(self):
if self.is_mutable():
raise ValueError('element must be immutable in order to be '
'hashable')
return hash((type(self).__name__, self._manifold))

return hash((type(self).__name__, self._domain))

0 comments on commit 37b0042

Please sign in to comment.