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

Commit

Permalink
ManifoldSubsetPullback: Prepare for pullbacks of opens
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Jun 3, 2021
1 parent 1623cc5 commit dcc1f9a
Showing 1 changed file with 54 additions and 3 deletions.
57 changes: 54 additions & 3 deletions src/sage/manifolds/subsets/pullback.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.categories.sets_cat import Sets
from sage.manifolds.subset import ManifoldSubset
from sage.manifolds.chart import Chart
from sage.sets.real_set import RealSet
Expand Down Expand Up @@ -147,7 +148,56 @@ def __classcall_private__(cls, map, inverse=None, codomain_subset=None,
if name is None:
name = inverse_name + '_' + codomain_subset_name

return super().__classcall__(cls, map, inverse, codomain_subset, name, latex_name)
if cls._is_open(codomain_subset):

try:
coord_def = cls._coord_def(codomain_subset)
except NotImplementedError:
pass
else:
return domain.open_subset(name=name, latex_name=latex_name, coord_def=coord_def)

self = super().__classcall__(cls, map, inverse, codomain_subset, name, latex_name)

return self

@staticmethod
def _is_open(codomain_subset):

if isinstance(codomain_subset, ManifoldSubset):
return codomain_subset.is_open()

if isinstance(codomain_subset, RealSet):
return codomain_subset.is_open()

if is_Polyhedron(codomain_subset):
return codomain_subset.is_empty() or codomain_subset.is_universe()

if codomain_subset in Sets().Finite():
return codomain.cardinality() == 0

if hasattr(codomain_subset, 'minimized_constraints'):
try:
from ppl import NNC_Polyhedron, C_Polyhedron
except ImportError:
pass
else:
if isinstance(codomain_subset, (NNC_Polyhedron, C_Polyhedron)):
cs = P.minimized_constraints()
if cs.has_equalities():
return False
if any(constraint.is_nonstrict_inequality()
for constraint in cs):
return False
return True

return False

@staticmethod
def _coord_def(codomain_subset):

raise NotImplementedError


def __init__(self, map, inverse, codomain_subset, name, latex_name):
r"""
Expand Down Expand Up @@ -239,8 +289,9 @@ def is_closed(self):
except ImportError:
pass
else:
# ppl polyhedra can decide closedness authoritatively
return self._codomain_subset.is_topologically_closed()
if isinstance(self._codomain_subset, (NNC_Polyhedron, C_Polyhedron)):
# ppl polyhedra can decide closedness authoritatively
return self._codomain_subset.is_topologically_closed()
return super().is_closed()

def closure(self, name=None, latex_name=None):
Expand Down

0 comments on commit dcc1f9a

Please sign in to comment.