From ced1988168c2399066520c9391e298b7a56a70aa Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 9 May 2021 12:52:56 -0700 Subject: [PATCH] CombinatorialPolyhedralSets: Add element methods dim/dimension, subcategory Finite with parent method dimension --- .../combinatorial_polyhedral_sets.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/sage/categories/combinatorial_polyhedral_sets.py b/src/sage/categories/combinatorial_polyhedral_sets.py index b4cfb887f18..05691ac541a 100644 --- a/src/sage/categories/combinatorial_polyhedral_sets.py +++ b/src/sage/categories/combinatorial_polyhedral_sets.py @@ -12,8 +12,10 @@ # https://www.gnu.org/licenses/ # **************************************************************************** +from sage.misc.abstract_method import abstract_method from sage.misc.cachefunc import cached_method from .category_singleton import Category_singleton +from .category_with_axiom import CategoryWithAxiom from .sets_cat import Sets class CombinatorialPolyhedralSets(Category_singleton): @@ -47,3 +49,38 @@ def super_categories(self): [Category of sets] """ return [Sets()] + + class ParentMethods: + + pass + + + class ElementMethods: + + @abstract_method + def dimension(self): + r""" + Return the dimension of the combinatorial polyhedron. + """ + + def dim(self): + r""" + Return the dimension of the combinatorial polyhedron. + + This is an alias for meth:`dimension`. + """ + return self.dimension() + + class Finite(CategoryWithAxiom): + """ + Category of finite sets of combinatorial polyhedra. + """ + + class ParentMethods: + + @cached_method + def dimension(self): + r""" + Return the maximum dimension of the combinatorial polyhedra in ``self``. + """ + return max(c.dimension for c in self)