Skip to content

Commit

Permalink
gh-36572: Replace relative imports by absolute ones in categories
Browse files Browse the repository at this point in the history
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes #1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

As preparation for compiling with meson, we replace relative imports by
absolute ones.
Relative imports are not used consistently in the codebase and result in
issues for doctesting with pytest (which admittedly is a limitation of
pytest). We normalize the relative imports in `sage.categories` to be
absolute imports. Small code-style improvements along the way (mainly to
nicely order the imports)

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #36572
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik
  • Loading branch information
Release Manager committed Dec 4, 2023
2 parents e86721e + df2f18d commit 9014410
Show file tree
Hide file tree
Showing 38 changed files with 271 additions and 233 deletions.
6 changes: 3 additions & 3 deletions src/sage/categories/action.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from sage.structure.element cimport Element
from .morphism cimport Morphism
from .map cimport Map
from .functor cimport Functor
from sage.categories.morphism cimport Morphism
from sage.categories.map cimport Map
from sage.categories.functor cimport Functor

cdef class Action(Functor):
cdef readonly G
Expand Down
8 changes: 4 additions & 4 deletions src/sage/categories/action.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ AUTHOR:

from cpython.tuple cimport PyTuple_GET_ITEM

from .functor cimport Functor
from .morphism cimport Morphism
from .map cimport Map
from sage.categories.functor cimport Functor
from sage.categories.morphism cimport Morphism
from sage.categories.map cimport Map
from sage.structure.element cimport parent
from sage.structure.parent cimport Parent

from . import homset
from sage.categories import homset
from weakref import ref


Expand Down
8 changes: 4 additions & 4 deletions src/sage/categories/algebra_ideals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
# https://www.gnu.org/licenses/
# *****************************************************************************

from .algebra_modules import AlgebraModules
from .algebras import Algebras
from .rings import Rings
from .category_types import Category_ideal
from sage.categories.algebra_modules import AlgebraModules
from sage.categories.algebras import Algebras
from sage.categories.category_types import Category_ideal
from sage.categories.rings import Rings


class AlgebraIdeals(Category_ideal):
Expand Down
9 changes: 5 additions & 4 deletions src/sage/categories/algebra_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
# http://www.gnu.org/licenses/
#******************************************************************************

from .category_types import Category_module
from .commutative_algebras import CommutativeAlgebras
from .commutative_rings import CommutativeRings
from .modules import Modules
from sage.categories.category_types import Category_module
from sage.categories.commutative_algebras import CommutativeAlgebras
from sage.categories.commutative_rings import CommutativeRings
from sage.categories.modules import Modules


class AlgebraModules(Category_module):
"""
Expand Down
8 changes: 4 additions & 4 deletions src/sage/categories/algebras_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
# https://www.gnu.org/licenses/
#******************************************************************************

from sage.categories.cartesian_product import CartesianProductsCategory
from sage.categories.category_with_axiom import CategoryWithAxiom_over_base_ring
from sage.categories.tensor import TensorProductsCategory, tensor
from sage.categories.unital_algebras import UnitalAlgebras
from sage.misc.cachefunc import cached_method
from sage.misc.lazy_attribute import lazy_attribute
from sage.misc.lazy_import import LazyImport
from sage.categories.tensor import TensorProductsCategory, tensor
from sage.categories.cartesian_product import CartesianProductsCategory
from sage.categories.category_with_axiom import CategoryWithAxiom_over_base_ring
from .unital_algebras import UnitalAlgebras


class AlgebrasWithBasis(CategoryWithAxiom_over_base_ring):
Expand Down
154 changes: 77 additions & 77 deletions src/sage/categories/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,128 +27,128 @@
from sage.misc.namespace_package import install_doc
install_doc(__package__, __doc__)

from . import primer
from sage.categories import primer

from sage.misc.lazy_import import lazy_import

from .all__sagemath_objects import *
from sage.categories.all__sagemath_objects import *

from .basic import *
from sage.categories.basic import *

from .chain_complexes import ChainComplexes, HomologyFunctor
from sage.categories.chain_complexes import ChainComplexes, HomologyFunctor

from .simplicial_complexes import SimplicialComplexes
from sage.categories.simplicial_complexes import SimplicialComplexes

from .tensor import tensor
from .signed_tensor import tensor_signed
from sage.categories.tensor import tensor
from sage.categories.signed_tensor import tensor_signed

from .g_sets import GSets
from .pointed_sets import PointedSets
from sage.categories.g_sets import GSets
from sage.categories.pointed_sets import PointedSets

from .sets_with_grading import SetsWithGrading
from sage.categories.sets_with_grading import SetsWithGrading

from .groupoid import Groupoid
from .permutation_groups import PermutationGroups
from sage.categories.groupoid import Groupoid
from sage.categories.permutation_groups import PermutationGroups

# enumerated sets
from .finite_sets import FiniteSets
from .enumerated_sets import EnumeratedSets
from .finite_enumerated_sets import FiniteEnumeratedSets
from .infinite_enumerated_sets import InfiniteEnumeratedSets
from sage.categories.finite_sets import FiniteSets
from sage.categories.enumerated_sets import EnumeratedSets
from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets
from sage.categories.infinite_enumerated_sets import InfiniteEnumeratedSets

# posets
from .posets import Posets
from .finite_posets import FinitePosets
from .lattice_posets import LatticePosets
from .finite_lattice_posets import FiniteLatticePosets
from sage.categories.posets import Posets
from sage.categories.finite_posets import FinitePosets
from sage.categories.lattice_posets import LatticePosets
from sage.categories.finite_lattice_posets import FiniteLatticePosets

# finite groups/...
from .finite_semigroups import FiniteSemigroups
from .finite_monoids import FiniteMonoids
from .finite_groups import FiniteGroups
from .finite_permutation_groups import FinitePermutationGroups
from sage.categories.finite_semigroups import FiniteSemigroups
from sage.categories.finite_monoids import FiniteMonoids
from sage.categories.finite_groups import FiniteGroups
from sage.categories.finite_permutation_groups import FinitePermutationGroups

# fields
from .number_fields import NumberFields
from .function_fields import FunctionFields
from sage.categories.number_fields import NumberFields
from sage.categories.function_fields import FunctionFields

# modules
from .left_modules import LeftModules
from .right_modules import RightModules
from .bimodules import Bimodules
from sage.categories.left_modules import LeftModules
from sage.categories.right_modules import RightModules
from sage.categories.bimodules import Bimodules

from .modules import Modules
from sage.categories.modules import Modules
RingModules = Modules
from .vector_spaces import VectorSpaces
from sage.categories.vector_spaces import VectorSpaces

# (hopf) algebra structures
from .algebras import Algebras
from .commutative_algebras import CommutativeAlgebras
from .coalgebras import Coalgebras
from .bialgebras import Bialgebras
from .hopf_algebras import HopfAlgebras
from .lie_algebras import LieAlgebras
from sage.categories.algebras import Algebras
from sage.categories.commutative_algebras import CommutativeAlgebras
from sage.categories.coalgebras import Coalgebras
from sage.categories.bialgebras import Bialgebras
from sage.categories.hopf_algebras import HopfAlgebras
from sage.categories.lie_algebras import LieAlgebras

# specific algebras
from .monoid_algebras import MonoidAlgebras
from .group_algebras import GroupAlgebras
from .matrix_algebras import MatrixAlgebras
from sage.categories.monoid_algebras import MonoidAlgebras
from sage.categories.group_algebras import GroupAlgebras
from sage.categories.matrix_algebras import MatrixAlgebras

# ideals
from .ring_ideals import RingIdeals
from sage.categories.ring_ideals import RingIdeals
Ideals = RingIdeals
from .commutative_ring_ideals import CommutativeRingIdeals
from .algebra_modules import AlgebraModules
from .algebra_ideals import AlgebraIdeals
from .commutative_algebra_ideals import CommutativeAlgebraIdeals
from sage.categories.commutative_ring_ideals import CommutativeRingIdeals
from sage.categories.algebra_modules import AlgebraModules
from sage.categories.algebra_ideals import AlgebraIdeals
from sage.categories.commutative_algebra_ideals import CommutativeAlgebraIdeals

# schemes and varieties
from .modular_abelian_varieties import ModularAbelianVarieties
from .schemes import Schemes
from sage.categories.modular_abelian_varieties import ModularAbelianVarieties
from sage.categories.schemes import Schemes

# * with basis
from .modules_with_basis import ModulesWithBasis
from sage.categories.modules_with_basis import ModulesWithBasis
FreeModules = ModulesWithBasis
from .hecke_modules import HeckeModules
from .algebras_with_basis import AlgebrasWithBasis
from .coalgebras_with_basis import CoalgebrasWithBasis
from .bialgebras_with_basis import BialgebrasWithBasis
from .hopf_algebras_with_basis import HopfAlgebrasWithBasis
from sage.categories.hecke_modules import HeckeModules
from sage.categories.algebras_with_basis import AlgebrasWithBasis
from sage.categories.coalgebras_with_basis import CoalgebrasWithBasis
from sage.categories.bialgebras_with_basis import BialgebrasWithBasis
from sage.categories.hopf_algebras_with_basis import HopfAlgebrasWithBasis

# finite dimensional * with basis
from .finite_dimensional_modules_with_basis import FiniteDimensionalModulesWithBasis
from .finite_dimensional_algebras_with_basis import FiniteDimensionalAlgebrasWithBasis
from .finite_dimensional_coalgebras_with_basis import FiniteDimensionalCoalgebrasWithBasis
from .finite_dimensional_bialgebras_with_basis import FiniteDimensionalBialgebrasWithBasis
from .finite_dimensional_hopf_algebras_with_basis import FiniteDimensionalHopfAlgebrasWithBasis
from sage.categories.finite_dimensional_modules_with_basis import FiniteDimensionalModulesWithBasis
from sage.categories.finite_dimensional_algebras_with_basis import FiniteDimensionalAlgebrasWithBasis
from sage.categories.finite_dimensional_coalgebras_with_basis import FiniteDimensionalCoalgebrasWithBasis
from sage.categories.finite_dimensional_bialgebras_with_basis import FiniteDimensionalBialgebrasWithBasis
from sage.categories.finite_dimensional_hopf_algebras_with_basis import FiniteDimensionalHopfAlgebrasWithBasis

# graded *
from .graded_modules import GradedModules
from .graded_algebras import GradedAlgebras
from .graded_coalgebras import GradedCoalgebras
from .graded_bialgebras import GradedBialgebras
from .graded_hopf_algebras import GradedHopfAlgebras
from sage.categories.graded_modules import GradedModules
from sage.categories.graded_algebras import GradedAlgebras
from sage.categories.graded_coalgebras import GradedCoalgebras
from sage.categories.graded_bialgebras import GradedBialgebras
from sage.categories.graded_hopf_algebras import GradedHopfAlgebras

# graded * with basis
from .graded_modules_with_basis import GradedModulesWithBasis
from .graded_algebras_with_basis import GradedAlgebrasWithBasis
from .graded_coalgebras_with_basis import GradedCoalgebrasWithBasis
from .graded_bialgebras_with_basis import GradedBialgebrasWithBasis
from .graded_hopf_algebras_with_basis import GradedHopfAlgebrasWithBasis
from sage.categories.graded_modules_with_basis import GradedModulesWithBasis
from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis
from sage.categories.graded_coalgebras_with_basis import GradedCoalgebrasWithBasis
from sage.categories.graded_bialgebras_with_basis import GradedBialgebrasWithBasis
from sage.categories.graded_hopf_algebras_with_basis import GradedHopfAlgebrasWithBasis

# Coxeter groups
from .coxeter_groups import CoxeterGroups
from sage.categories.coxeter_groups import CoxeterGroups
lazy_import('sage.categories.finite_coxeter_groups', 'FiniteCoxeterGroups')
from .weyl_groups import WeylGroups
from .finite_weyl_groups import FiniteWeylGroups
from .affine_weyl_groups import AffineWeylGroups
from sage.categories.weyl_groups import WeylGroups
from sage.categories.finite_weyl_groups import FiniteWeylGroups
from sage.categories.affine_weyl_groups import AffineWeylGroups

# crystal bases
from .crystals import Crystals
from .highest_weight_crystals import HighestWeightCrystals
from .regular_crystals import RegularCrystals
from .finite_crystals import FiniteCrystals
from .classical_crystals import ClassicalCrystals
from sage.categories.crystals import Crystals
from sage.categories.highest_weight_crystals import HighestWeightCrystals
from sage.categories.regular_crystals import RegularCrystals
from sage.categories.finite_crystals import FiniteCrystals
from sage.categories.classical_crystals import ClassicalCrystals

# polyhedra
lazy_import('sage.categories.polyhedra', 'PolyhedralSets')
Expand Down
27 changes: 12 additions & 15 deletions src/sage/categories/all__sagemath_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,25 @@

# Resolve a circular import so that "import sage.categories.all" can succeed
# in initializing the category system.
import sage.structure.category_object # imports sage.categories.category
import sage.structure.category_object # imports sage.categories.category

# Small part of "from .basic import *":
from .objects import Objects
from .sets_cat import Sets, EmptySetError
# Small part of "from sage.categories.basic import *":
from sage.categories.objects import Objects
from sage.categories.sets_cat import Sets, EmptySetError


from .category import Category
from sage.categories.category import Category

from .category_types import Elements
from sage.categories.category_types import Elements

from .cartesian_product import cartesian_product
from sage.categories.cartesian_product import cartesian_product

from .functor import (ForgetfulFunctor,
IdentityFunctor)
from sage.categories.functor import ForgetfulFunctor, IdentityFunctor

from .homset import (Hom, hom,
End, end,
Homset, HomsetWithBase)
from sage.categories.homset import Hom, hom, End, end, Homset, HomsetWithBase

from .morphism import Morphism
from sage.categories.morphism import Morphism

from .realizations import Realizations
from sage.categories.realizations import Realizations

from .sets_with_partial_maps import SetsWithPartialMaps
from sage.categories.sets_with_partial_maps import SetsWithPartialMaps
Loading

0 comments on commit 9014410

Please sign in to comment.