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

Commit

Permalink
ManifoldSubset.declare_{sub,super}set: New
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Apr 30, 2021
1 parent 0666fae commit 426e087
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/sage/manifolds/manifold.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,10 @@ def open_subset(self, name, latex_name=None, coord_def={}):
latex_name=latex_name,
start_index=self._sindex)
resu._calculus_method = self._calculus_method
resu._supersets.update(self._supersets)
for sd in self._supersets:
sd._subsets.add(resu)
if self.is_empty():
self.declare_equal(resu)
else:
self.declare_superset(resu)
self._top_subsets.add(resu)
# Charts on the result from the coordinate definition:
for chart, restrictions in coord_def.items():
Expand Down
25 changes: 19 additions & 6 deletions src/sage/manifolds/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,10 @@ def subset(self, name, latex_name=None, is_open=False):
if is_open:
return self.open_subset(name, latex_name=latex_name)
res = ManifoldSubset(self._manifold, name, latex_name=latex_name)
res._supersets.update(self._supersets)
for sd in self._supersets:
sd._subsets.add(res)
if self.is_empty():
self.declare_equal(res)
else:
self.declare_superset(res)
self._top_subsets.add(res)
return res

Expand Down Expand Up @@ -935,16 +936,28 @@ def superset(self, name, latex_name=None, is_open=False):
res = self._manifold.open_subset(name, latex_name=latex_name)
else:
res = ManifoldSubset(self._manifold, name, latex_name=latex_name)
res._subsets.update(self._subsets)
for sd in self._subsets:
sd._supersets.add(res)
res.declare_superset(self)
if is_open and self._is_open:
res._atlas = list(self._atlas)
res._top_charts = list(self._top_charts)
res._coord_changes = dict(self._coord_changes)
res._def_chart = self._def_chart
return res

def declare_subset(self, *supersets):
supersets = ManifoldSubsetFiniteFamily.from_subsets_or_families(*supersets)
for superset in supersets:
superset._subsets.update(self._subsets)
for subset in self._subsets:
subset._supersets.update(supersets)

def declare_superset(self, *subsets):
subsets = ManifoldSubsetFiniteFamily.from_subsets_or_families(*subsets)
for subset in subsets:
subset._supersets.update(self._supersets)
for superset in self._supersets:
superset._subsets.update(subsets)

def intersection(self, other, name=None, latex_name=None):
r"""
Return the intersection of the current subset with another subset.
Expand Down

0 comments on commit 426e087

Please sign in to comment.