Skip to content

Commit

Permalink
Trac #29881: sage.categories: Replace imports from sage.rings.all by …
Browse files Browse the repository at this point in the history
…more specific imports

`sage.rings.all` has a mixture of generic classes and implementation
classes. Some of the generic and/or basic ones will probably have to be
included in `sage-objects` (#29865). We prepare this by getting rid of
imports from `sage.rings.all` throughout `sage.categories`.

URL: https://trac.sagemath.org/29881
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): Travis Scrimshaw, Frédéric Chapoton
  • Loading branch information
Release Manager committed Jul 4, 2020
2 parents 9966288 + 82676e6 commit 13c8790
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/sage/categories/bimodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def an_instance(cls):
sage: Bimodules.an_instance()
Category of bimodules over Rational Field on the left and Real Field with 53 bits of precision on the right
"""
from sage.rings.all import QQ, RR
from sage.rings.rational_field import QQ
from sage.rings.real_mpfr import RR
return cls(QQ, RR)

def _repr_object_names(self):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/coalgebras_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def coproduct_iterated(self, n=1):
if n == 1:
return self.coproduct()
from sage.functions.all import floor, ceil
from sage.rings.all import Integer
from sage.rings.integer import Integer

# Use coassociativity of `\Delta` to perform many coproducts simultaneously.
fn = floor(Integer(n-1)/2); cn = ceil(Integer(n-1)/2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def simple_reflection_orders(self):
"""
one = self.one()
s = self.simple_reflections()
from sage.rings.all import ZZ
from sage.rings.integer_ring import ZZ

def mult_order(x):
ct = ZZ.one()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/euclidean_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _test_euclidean_degree(self, **options):

min_degree = self.one().euclidean_degree()

from sage.rings.all import NN
from sage.rings.semirings.non_negative_integer_semiring import NN
for a in S:
tester.assertIn(a.euclidean_degree(), NN)
tester.assertGreaterEqual(a.euclidean_degree(), min_degree)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def euclidean_degree(self):
"""
if self.is_zero():
raise ValueError("euclidean degree not defined for the zero element")
from sage.rings.all import ZZ
from sage.rings.integer_ring import ZZ
return ZZ.zero()

def quo_rem(self, other):
Expand Down
6 changes: 3 additions & 3 deletions src/sage/categories/finite_complex_reflection_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def number_of_reflection_hyperplanes(self):
sage: W.number_of_reflection_hyperplanes() # optional - gap3
15
"""
from sage.rings.all import ZZ
from sage.rings.integer_ring import ZZ
return ZZ.sum(codeg + 1 for codeg in self.codegrees())

@cached_method
Expand Down Expand Up @@ -358,7 +358,7 @@ def number_of_reflections(self):
sage: W.number_of_reflections() # optional - gap3
15
"""
from sage.rings.all import ZZ
from sage.rings.integer_ring import ZZ
return ZZ.sum(deg - 1 for deg in self.degrees())

@cached_method
Expand Down Expand Up @@ -413,7 +413,7 @@ def cardinality(self):
sage: W.cardinality() # optional - gap3
192
"""
from sage.rings.all import ZZ
from sage.rings.integer_ring import ZZ
return ZZ.prod(self.degrees())

def is_well_generated(self):
Expand Down
6 changes: 3 additions & 3 deletions src/sage/categories/finite_coxeter_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
from sage.misc.lazy_attribute import lazy_attribute
from sage.categories.category_with_axiom import CategoryWithAxiom
from sage.categories.coxeter_groups import CoxeterGroups
from sage.rings.all import AA, UniversalCyclotomicField, QQbar
from sage.rings.integer_ring import ZZ


class FiniteCoxeterGroups(CategoryWithAxiom):
r"""
Expand Down Expand Up @@ -742,9 +739,12 @@ def permutahedron(self, point=None, base_ring=None):
n = self.one().canonical_matrix().rank()
weights = self.fundamental_weights()
if point is None:
from sage.rings.integer_ring import ZZ
point = [ZZ.one()] * n
v = sum(point[i-1] * weights[i] for i in weights.keys())
from sage.geometry.polyhedron.constructor import Polyhedron
from sage.rings.qqbar import AA, QQbar
from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField
vertices = [v*w for w in self]
if base_ring is None and v.base_ring() in [UniversalCyclotomicField(), QQbar]:
vertices = [v.change_ring(AA) for v in vertices]
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def free(index_set=None, names=None, **kwds):
sage: F.<x,y,z> = Groups().free(); F
Free Group on generators {x, y, z}
"""
from sage.rings.all import ZZ
from sage.rings.integer_ring import ZZ
if index_set in ZZ or (index_set is None and names is not None):
from sage.groups.free_group import FreeGroup
if names is None:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/highest_weight_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def q_dimension(self, q=None, prec=None, use_product=False):
+ 36*q^12 + 44*q^13 + 57*q^14 + 70*q^15 + O(x^16)
"""
from sage.rings.all import ZZ
from sage.rings.integer_ring import ZZ
WLR = self.weight_lattice_realization()
I = self.index_set()
mg = self.highest_weight_vectors()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/lie_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def example(self, gens=None):
"""
if gens is None:
from sage.combinat.symmetric_group_algebra import SymmetricGroupAlgebra
from sage.rings.all import QQ
from sage.rings.rational_field import QQ
gens = SymmetricGroupAlgebra(QQ, 3).algebra_generators()
from sage.categories.examples.lie_algebras import Example
return Example(gens)
Expand Down
5 changes: 3 additions & 2 deletions src/sage/categories/loop_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
from sage.categories.map import Map
from sage.graphs.dot2tex_utils import have_dot2tex
from sage.functions.other import ceil
from sage.rings.all import ZZ


class LoopCrystals(Category_singleton):
r"""
Expand Down Expand Up @@ -534,6 +532,7 @@ def is_perfect(self, ell=None):
Implement a version for tensor products of KR crystals.
"""
from sage.rings.integer_ring import ZZ
if ell is None:
if (self.cartan_type().dual().type() == 'BC'
and self.cartan_type().rank() - 1 == self.r()):
Expand Down Expand Up @@ -978,6 +977,7 @@ def energy_function(self, algorithm=None):

if algorithm == 'definition':
# Setup
from sage.rings.integer_ring import ZZ
energy = ZZ.zero()
R_mats = [[K.R_matrix(Kp) for Kp in self.parent().crystals[i+1:]]
for i,K in enumerate(self.parent().crystals)]
Expand Down Expand Up @@ -1179,6 +1179,7 @@ def __init__(self, B, Bp, normalization=0):
sage: [H(x) for x in hw]
[0, 1, 2, 1]
"""
from sage.rings.integer_ring import ZZ
self._B = B
self._Bp = Bp
self._R_matrix = self._B.R_matrix(self._Bp)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/categories/monoids.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def free(index_set=None, names=None, **kwds):
"""
if names is not None:
if isinstance(names, str):
from sage.rings.all import ZZ
from sage.rings.integer_ring import ZZ
if ',' not in names and index_set in ZZ:
names = [names + repr(i) for i in range(index_set)]
else:
Expand Down Expand Up @@ -349,7 +349,7 @@ def free(index_set=None, names=None, **kwds):
"""
if names is not None:
if isinstance(names, str):
from sage.rings.all import ZZ
from sage.rings.integer_ring import ZZ
if ',' not in names and index_set in ZZ:
names = [names + repr(i) for i in range(index_set)]
else:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/regular_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def demazure_subcrystal(self, element, reduced_word, only_support=True):
([[2, 2]], [[1, 2]], 0)]
"""
from sage.combinat.free_module import CombinatorialFreeModule
from sage.rings.all import QQ
from sage.rings.rational_field import QQ
C = CombinatorialFreeModule(QQ, self)
D = self.demazure_operator(C(element), reduced_word)
if only_support:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/supercrystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def character(self):
B[(1, 0, 0, 0, 0)] + B[(0, 1, 0, 0, 0)] + B[(0, 0, 1, 0, 0)]
+ B[(0, 0, 0, 1, 0)] + B[(0, 0, 0, 0, 1)]
"""
from sage.rings.all import ZZ
from sage.rings.integer_ring import ZZ
A = self.weight_lattice_realization().algebra(ZZ)
return A.sum(A(x.weight()) for x in self)

Expand Down

0 comments on commit 13c8790

Please sign in to comment.