Source code for flatsurf.geometry.categories.surface_category
r"""Category types for surfaces.This module provides alternative implementations for the SageMath types``Category`` and ``CategoryWithAxiom``. It patches the ``_cmp_key`` of thesetypes to produce a more stable sorting of surface categories exactly in thesame way that SageMath does for its builtin categories.Without this, the MRO of surfaces is session dependent and in particular we getsomewhat random printing of categories such as translation surfaces.While we do not claim to actually understand all the details here, you canconsult ``c3_controlled.py`` in SageMath for all the (rather technical)details."""# ##################################################################### This file is part of sage-flatsurf.## Copyright (C) 2023 Julian Rüth## sage-flatsurf is free software: you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation, either version 2 of the License, or# (at your option) any later version.## sage-flatsurf is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with sage-flatsurf. If not, see <https://www.gnu.org/licenses/>.# ####################################################################importsage.categories.categoryimportsage.categories.category_with_axiomfromsage.misc.c3_controlledimport_cmp_keyflags={atom:1<<(30-i)fori,atominenumerate(["TopologicalSurfaces","PolygonalSurfaces","EuclideanPolygonalSurfaces","SimilaritySurfaces","ConeSurfaces","DilationSurfaces","HalfTranslationSurfaces","TranslationSurfaces",])}