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

Commit

Permalink
ConvexSet_base.is_compact, ConvexSet_compact: New
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Jun 7, 2021
1 parent b2ac639 commit ccc8421
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
43 changes: 43 additions & 0 deletions src/sage/geometry/convex_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ def is_closed(self):
"""

def is_compact(self):
r"""
Return whether ``self`` is compact.
OUTPUT:
Boolean.
"""
if not self.is_closed():
return False
if self.dimension() < 1:
return True
raise NotImplementedError

def closure(self):
r"""
Return the topological closure of ``self``.
Expand Down Expand Up @@ -152,6 +167,34 @@ def is_open(self):
return self.is_empty() or self.is_universe()


class ConvexSet_compact(ConvexSet_closed):

r"""
Abstract base class for compact convex sets.
"""

def is_universe(self):
r"""
Return whether ``self`` is the whole ambient space
OUTPUT:
Boolean.
"""
return self.ambient_dim() == 0 and not self.is_empty()

def is_compact(self):
r"""
Return whether ``self`` is compact.
OUTPUT:
Boolean.
"""
return True


class ConvexSet_relatively_open(ConvexSet_base):

r"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/geometry/lattice_polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
from sage.structure.all import Sequence
from sage.structure.sage_object import SageObject
from sage.structure.richcmp import richcmp_method, richcmp
from sage.geometry.convex_set import ConvexSet_closed
from sage.geometry.convex_set import ConvexSet_compact

from copy import copy
from collections.abc import Hashable
Expand Down Expand Up @@ -465,7 +465,7 @@ def is_LatticePolytope(x):
return isinstance(x, LatticePolytopeClass)

@richcmp_method
class LatticePolytopeClass(ConvexSet_closed, Hashable):
class LatticePolytopeClass(ConvexSet_compact, Hashable):
r"""
Create a lattice polytope.
Expand Down

0 comments on commit ccc8421

Please sign in to comment.