Skip to content

Commit

Permalink
gh-35012: Issue #34949: sage.{categories,matrix,structure}: Replace i…
Browse files Browse the repository at this point in the history
…mports from sage.*.all for namespace packages

    
Closes #34949
    
URL: #35012
Reported by: Matthias Köppe
Reviewer(s): Tobias Diez
  • Loading branch information
Release Manager committed Feb 21, 2023
2 parents c6508c5 + d905cc3 commit cf49215
Show file tree
Hide file tree
Showing 61 changed files with 188 additions and 153 deletions.
7 changes: 4 additions & 3 deletions src/sage/arith/long.pxd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# sage.doctest: optional - sage.misc.cython
r"""
Fast conversion of Python objects to C long
"""
Expand Down Expand Up @@ -113,7 +114,7 @@ cdef inline bint integer_check_long(x, long* value, int* err) except -1:
We create a pure Python wrapper of this function::
sage: cython(''' # optional - sage.misc.cython
sage: cython('''
....: from sage.arith.long cimport *
....: from sage.rings.integer cimport smallInteger
....: def check_long(x):
Expand Down Expand Up @@ -246,7 +247,7 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
We create a pure Python wrapper of this function::
sage: cython(''' # optional - sage.misc.cython
sage: cython('''
....: from sage.arith.long cimport *
....: def check_long_py(x):
....: cdef long value
Expand Down Expand Up @@ -387,7 +388,7 @@ cdef inline bint is_small_python_int(obj):
EXAMPLES::
sage: cython(''' # optional - sage.misc.cython
sage: cython('''
....: from sage.arith.long cimport is_small_python_int
....: def is_small_wrapper(x):
....: return is_small_python_int(x)
Expand Down
3 changes: 2 additions & 1 deletion src/sage/categories/bialgebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
# *****************************************************************************

from sage.categories.category_types import Category_over_base_ring
from sage.categories.all import Algebras, Coalgebras
from sage.categories.algebras import Algebras
from sage.categories.coalgebras import Coalgebras
from sage.categories.super_modules import SuperModulesCategory
from sage.misc.lazy_import import LazyImport

Expand Down
4 changes: 2 additions & 2 deletions src/sage/categories/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Category(UniqueRepresentation, SageObject):
This is achieved as follows::
sage: from sage.categories.all import Category
sage: from sage.categories.category import Category
sage: class EuclideanDomains(Category):
....: # operations on the category itself
....: def super_categories(self):
Expand Down Expand Up @@ -201,7 +201,7 @@ class inheritance from ``C.parent_class``.
::
sage: from sage.categories.all import Category
sage: from sage.categories.category import Category
sage: from sage.misc.lazy_attribute import lazy_attribute
sage: class As (Category):
....: def super_categories(self):
Expand Down
4 changes: 3 additions & 1 deletion src/sage/categories/chain_complexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def super_categories(self):
[Category of modules over Ring of integers modulo 9]
"""
from sage.categories.all import Fields, Modules, VectorSpaces
from sage.categories.fields import Fields
from sage.categories.modules import Modules
from sage.categories.vector_spaces import VectorSpaces
base_ring = self.base_ring()
if base_ring in Fields():
return [VectorSpaces(base_ring)]
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/coalgebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# *****************************************************************************

from .category_types import Category_over_base_ring
from sage.categories.all import Modules
from sage.categories.modules import Modules
from sage.categories.category_with_axiom import CategoryWithAxiom_over_base_ring
from sage.categories.tensor import TensorProductsCategory
from sage.categories.dual import DualObjectsCategory
Expand Down
4 changes: 3 additions & 1 deletion src/sage/categories/coalgebras_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
from sage.misc.lazy_attribute import lazy_attribute
from sage.misc.lazy_import import LazyImport
from sage.categories.category_with_axiom import CategoryWithAxiom_over_base_ring
from sage.categories.all import ModulesWithBasis, tensor, Hom
from sage.categories.modules_with_basis import ModulesWithBasis
from sage.categories.tensor import tensor
from sage.categories.homset import Hom
from sage.categories.super_modules import SuperModulesCategory
from sage.categories.filtered_modules import FilteredModulesCategory

Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/algebras_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from sage.misc.cachefunc import cached_method
from sage.sets.family import Family
from sage.categories.all import AlgebrasWithBasis
from sage.categories.algebras_with_basis import AlgebrasWithBasis
from sage.combinat.free_module import CombinatorialFreeModule
from sage.combinat.words.words import Words

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from sage.misc.cachefunc import cached_method
from sage.structure.parent import Parent
from sage.categories.all import CommutativeAdditiveMonoids
from sage.categories.commutative_additive_monoids import CommutativeAdditiveMonoids
from .commutative_additive_semigroups import FreeCommutativeAdditiveSemigroup

class FreeCommutativeAdditiveMonoid(FreeCommutativeAdditiveSemigroup):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sage.structure.parent import Parent
from sage.structure.element_wrapper import ElementWrapper
from sage.structure.unique_representation import UniqueRepresentation
from sage.categories.all import CommutativeAdditiveSemigroups
from sage.categories.commutative_additive_semigroups import CommutativeAdditiveSemigroups
from sage.sets.family import Family

class FreeCommutativeAdditiveSemigroup(UniqueRepresentation, Parent):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/finite_coxeter_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from sage.misc.cachefunc import cached_method
from sage.structure.parent import Parent
from sage.structure.element_wrapper import ElementWrapper
from sage.categories.all import FiniteCoxeterGroups
from sage.categories.finite_coxeter_groups import FiniteCoxeterGroups
from sage.structure.unique_representation import UniqueRepresentation
from sage.misc.functional import is_odd, is_even
from sage.combinat.root_system.coxeter_matrix import CoxeterMatrix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#*****************************************************************************

from sage.misc.cachefunc import cached_method
from sage.categories.all import FiniteDimensionalAlgebrasWithBasis
from sage.categories.finite_dimensional_algebras_with_basis import FiniteDimensionalAlgebrasWithBasis
from sage.combinat.free_module import CombinatorialFreeModule


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from sage.misc.cachefunc import cached_method
from sage.sets.family import Family
from sage.categories.all import LieAlgebras
from sage.categories.lie_algebras import LieAlgebras
from sage.modules.free_module import FreeModule
from sage.structure.parent import Parent
from sage.structure.unique_representation import UniqueRepresentation
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/finite_monoids.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from sage.structure.parent import Parent
from sage.structure.unique_representation import UniqueRepresentation
from sage.structure.element_wrapper import ElementWrapper
from sage.categories.all import Monoids
from sage.categories.monoids import Monoids
from sage.rings.integer import Integer
from sage.rings.integer_ring import ZZ

Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/finite_weyl_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from sage.misc.cachefunc import cached_method
from sage.structure.parent import Parent
from sage.structure.element_wrapper import ElementWrapper
from sage.categories.all import FiniteWeylGroups
from sage.categories.finite_weyl_groups import FiniteWeylGroups
from sage.structure.unique_representation import UniqueRepresentation

class SymmetricGroup(UniqueRepresentation, Parent):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/categories/examples/hopf_algebras_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

from sage.misc.cachefunc import cached_method
from sage.sets.family import Family
from sage.categories.all import HopfAlgebrasWithBasis
from sage.categories.hopf_algebras_with_basis import HopfAlgebrasWithBasis
from sage.combinat.free_module import CombinatorialFreeModule
from sage.categories.all import tensor
from sage.categories.tensor import tensor

class MyGroupAlgebra(CombinatorialFreeModule):
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/lie_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#from sage.misc.cachefunc import cached_method
from sage.sets.family import Family
from sage.categories.all import LieAlgebras
from sage.categories.lie_algebras import LieAlgebras
from sage.structure.parent import Parent
from sage.structure.unique_representation import UniqueRepresentation
from sage.structure.element_wrapper import ElementWrapper
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/magmas.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from sage.structure.parent import Parent
from sage.structure.unique_representation import UniqueRepresentation
from sage.structure.element_wrapper import ElementWrapper
from sage.categories.all import Magmas
from sage.categories.magmas import Magmas
from sage.sets.family import Family


Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/monoids.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from sage.misc.cachefunc import cached_method
from sage.structure.parent import Parent
from sage.structure.element_wrapper import ElementWrapper
from sage.categories.all import Monoids
from sage.categories.monoids import Monoids
from .semigroups import FreeSemigroup
from sage.sets.family import Family

Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/posets.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from sage.structure.parent import Parent
from sage.structure.unique_representation import UniqueRepresentation
from sage.categories.all import Posets
from sage.categories.posets import Posets
from sage.structure.element_wrapper import ElementWrapper
from sage.sets.set import Set, Set_object_enumerated
from sage.sets.positive_integers import PositiveIntegers
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/semigroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sage.structure.parent import Parent
from sage.structure.unique_representation import UniqueRepresentation
from sage.structure.element_wrapper import ElementWrapper
from sage.categories.all import Semigroups
from sage.categories.semigroups import Semigroups
from sage.sets.family import Family

class LeftZeroSemigroup(UniqueRepresentation, Parent):
Expand Down
3 changes: 2 additions & 1 deletion src/sage/categories/examples/semigroups_cython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Examples of semigroups in cython

from sage.structure.parent cimport Parent
from sage.structure.element cimport Element
from sage.categories.all import Category, Semigroups
from sage.categories.category import Category
from sage.categories.semigroups import Semigroups
from sage.categories.examples.semigroups import LeftZeroSemigroup as LeftZeroSemigroupPython
from cpython.object cimport PyObject_RichCompare

Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/sets_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from sage.categories.sets_cat import Sets
from sage.rings.integer import Integer, IntegerWrapper
from sage.rings.integer_ring import IntegerRing
from sage.arith.all import is_prime
from sage.arith.misc import is_prime
from sage.structure.unique_representation import UniqueRepresentation


Expand Down
4 changes: 3 additions & 1 deletion src/sage/categories/examples/with_realizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

from sage.misc.cachefunc import cached_method
from sage.misc.bindable_class import BindableClass
from sage.categories.all import Rings, Algebras, AlgebrasWithBasis
from sage.categories.rings import Rings
from sage.categories.algebras import Algebras
from sage.categories.algebras_with_basis import AlgebrasWithBasis
from sage.categories.realizations import Category_realization_of_parent
from sage.structure.unique_representation import UniqueRepresentation
from sage.structure.parent import Parent
Expand Down
4 changes: 2 additions & 2 deletions src/sage/categories/finite_complex_reflection_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def base_change_matrix(self):
[ 1 0]
[E(4) 1]
"""
from sage.matrix.all import Matrix
from sage.matrix.constructor import Matrix
return Matrix(list(self.independent_roots())).inverse()

class ElementMethods:
Expand Down Expand Up @@ -1187,7 +1187,7 @@ def rational_catalan_number(self, p, polynomial=False):
sage: W.rational_catalan_number(3, polynomial=True)
q^6 + q^4 + q^3 + q^2 + 1
"""
from sage.arith.all import gcd
from sage.arith.misc import GCD as gcd
from sage.combinat.q_analogues import q_int

h = self.coxeter_number()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ def FiniteDimensionalBialgebrasWithBasis(base_ring):
sage: TestSuite(C).run()
"""
from sage.categories.all import BialgebrasWithBasis
from sage.categories.bialgebras_with_basis import BialgebrasWithBasis
return BialgebrasWithBasis(base_ring).FiniteDimensional()
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ def FiniteDimensionalCoalgebrasWithBasis(base_ring):
sage: TestSuite(C).run()
"""
from sage.categories.all import CoalgebrasWithBasis
from sage.categories.coalgebras_with_basis import CoalgebrasWithBasis
return CoalgebrasWithBasis(base_ring).FiniteDimensional()
2 changes: 1 addition & 1 deletion src/sage/categories/graded_bialgebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ def GradedBialgebras(base_ring):
sage: TestSuite(C).run()
"""
from sage.categories.all import Bialgebras
from sage.categories.bialgebras import Bialgebras
return Bialgebras(base_ring).Graded()
2 changes: 1 addition & 1 deletion src/sage/categories/graded_bialgebras_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ def GradedBialgebrasWithBasis(base_ring):
sage: TestSuite(C).run()
"""
from sage.categories.all import BialgebrasWithBasis
from sage.categories.bialgebras_with_basis import BialgebrasWithBasis
return BialgebrasWithBasis(base_ring).Graded()
2 changes: 1 addition & 1 deletion src/sage/categories/graded_hopf_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ def GradedHopfAlgebras(base_ring):
:class:`super Hopf algebras
<sage.categories.hopf_algebras.HopfAlgebras.Super>`.
"""
from sage.categories.all import HopfAlgebras
from sage.categories.hopf_algebras import HopfAlgebras
return HopfAlgebras(base_ring).Graded()
2 changes: 1 addition & 1 deletion src/sage/categories/map.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ cdef class Section(Map):
To: Multivariate Polynomial Ring in x, y over Rational Field
"""
from sage.categories.homset import Hom
from sage.categories.all import SetsWithPartialMaps
from sage.categories.sets_with_partial_maps import SetsWithPartialMaps
Map.__init__(self, Hom(map.codomain(), map.domain(), SetsWithPartialMaps()))
self._inverse = map # TODO: Use this attribute somewhere!

Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/monoid_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ def MonoidAlgebras(base_ring):
sage: TestSuite(MonoidAlgebras(ZZ)).run()
"""
from sage.categories.all import Monoids
from sage.categories.monoids import Monoids
return Monoids().Algebras(base_ring)
2 changes: 1 addition & 1 deletion src/sage/categories/schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _call_(self, x):
from sage.categories.commutative_rings import CommutativeRings
from sage.schemes.generic.spec import Spec
from sage.categories.map import Map
from sage.categories.all import Rings
from sage.categories.rings import Rings
if x in CommutativeRings():
return Spec(x)
elif isinstance(x, Map) and x.category_for().is_subcategory(Rings()):
Expand Down
10 changes: 6 additions & 4 deletions src/sage/cpython/cython_metaclass.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ In Python, this would be ``meta.__init__(cls, name, bases, dict)``.
EXAMPLES::
sage: cython(''' # optional - sage.misc.cython
sage: cython( # optional - sage.misc.cython
....: '''
....: cimport sage.cpython.cython_metaclass
....: cdef class MyCustomType():
....: def __getmetaclass__(_):
Expand All @@ -75,9 +76,9 @@ EXAMPLES::
....: ''')
Calling MyMetaclass.__init__(<class '...MyCustomType'>, None, None, None)
Calling MyMetaclass.__init__(<class '...MyDerivedType'>, None, None, None)
sage: MyCustomType.__class__
sage: MyCustomType.__class__ # optional - sage.misc.cython
<class '...MyMetaclass'>
sage: class MyPythonType(MyDerivedType):
sage: class MyPythonType(MyDerivedType): # optional - sage.misc.cython
....: pass
Calling MyMetaclass.__init__(<class '...MyPythonType'>, 'MyPythonType', (<class '...MyDerivedType'>,), {...})
Expand All @@ -98,7 +99,8 @@ TESTS:
Check that a proper exception is raised if ``__getmetaclass__``
returns a non-type::
sage: cython(''' # optional - sage.misc.cython
sage: cython( # optional - sage.misc.cython
....: '''
....: cimport sage.cpython.cython_metaclass
....: cdef class MyCustomType():
....: def __getmetaclass__(_):
Expand Down
3 changes: 2 additions & 1 deletion src/sage/cpython/string.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ TESTS:
Check that this can be used outside of Sage (see :trac:`25549`)::
sage: cython(''' # optional - sage.misc.cython
sage: cython( # optional - sage.misc.cython
....: '''
....: from sage.cpython.string cimport char_to_str
....: print(char_to_str("hello world!"))
....: ''')
Expand Down
Loading

0 comments on commit cf49215

Please sign in to comment.