Skip to content

Commit c45fb47

Browse files
author
Release Manager
committed
sagemathgh-39131: avoid some imports of rings.Ring getting rid of some imports of `rings.Ring` ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: sagemath#39131 Reported by: Frédéric Chapoton Reviewer(s): Martin Rubey
2 parents e1c7e5a + ff83c55 commit c45fb47

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

src/sage/graphs/chrompoly.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ from memory_allocator cimport MemoryAllocator
3131
from sage.libs.gmp.mpz cimport *
3232
from sage.rings.integer_ring import ZZ
3333
from sage.rings.integer cimport Integer
34-
from sage.rings.ring cimport Ring
34+
from sage.rings.ring cimport CommutativeRing
3535
from sage.rings.polynomial.polynomial_integer_dense_flint cimport Polynomial_integer_dense_flint
3636
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
3737

@@ -436,7 +436,7 @@ def chromatic_polynomial_with_cache(G, cache=None):
436436
...
437437
TypeError: parameter cache must be a dictionary or None
438438
"""
439-
cdef Ring R = PolynomialRing(ZZ, "x", implementation="FLINT")
439+
cdef CommutativeRing R = PolynomialRing(ZZ, "x", implementation="FLINT")
440440
cdef Polynomial_integer_dense_flint one = R.one()
441441
cdef Polynomial_integer_dense_flint zero = R.zero()
442442
cdef Polynomial_integer_dense_flint x = R.gen()

src/sage/modular/pollack_stevens/distributions.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@
3939
# https://www.gnu.org/licenses/
4040
# *************************************************************************
4141

42+
from sage.categories.commutative_rings import CommutativeRings
4243
from sage.categories.fields import Fields
4344
from sage.categories.modules import Modules
4445
from sage.misc.cachefunc import cached_method
4546
from sage.misc.lazy_import import lazy_import
4647
from sage.modules.module import Module
4748
from sage.rings.integer_ring import ZZ
4849
from sage.rings.rational_field import QQ
49-
from sage.rings.ring import Ring
5050
from sage.structure.factory import UniqueFactory
5151
from sage.structure.parent import Parent
5252
from .sigma0 import _default_adjuster
@@ -281,8 +281,8 @@ def __init__(self, k, p=None, prec_cap=None, base=None, character=None,
281281
...
282282
ValueError: p must be prime
283283
"""
284-
if not isinstance(base, Ring):
285-
raise TypeError("base must be a ring")
284+
if base not in CommutativeRings():
285+
raise TypeError("base must be a commutative ring")
286286
# from sage.rings.padics.pow_computer import PowComputer
287287
# should eventually be the PowComputer on ZpCA once that uses longs.
288288
Dist, WeightKAction = get_dist_classes(p, prec_cap, base,
@@ -649,10 +649,13 @@ def __init__(self, k, base, character, adjuster, act_on_left, dettwist,
649649
if hasattr(base, 'prime'):
650650
p = base.prime()
651651
else:
652-
p = ZZ(0)
653-
OverconvergentDistributions_abstract.__init__(self, k, p, k + 1, base, character,
654-
adjuster, act_on_left, dettwist,
655-
act_padic, implementation)
652+
p = ZZ.zero()
653+
OverconvergentDistributions_abstract.__init__(self, k, p, k + 1,
654+
base, character,
655+
adjuster, act_on_left,
656+
dettwist,
657+
act_padic,
658+
implementation)
656659

657660
def _an_element_(self):
658661
r"""

src/sage/rings/number_field/number_field.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@
7575
# https://www.gnu.org/licenses/
7676
# ****************************************************************************
7777
from __future__ import annotations
78+
from itertools import count
79+
from collections import Counter
80+
7881
from sage.misc.cachefunc import cached_method
7982
from sage.misc.superseded import deprecation
8083

81-
8284
import sage.libs.ntl.all as ntl
8385
import sage.rings.abc
8486
import sage.rings.complex_mpfr
@@ -99,7 +101,6 @@
99101
from sage.rings.finite_rings.integer_mod import mod
100102
from sage.categories.number_fields import NumberFields
101103

102-
from sage.rings.ring import Ring
103104
from sage.misc.latex import latex_variable_name
104105

105106
from .unit_group import UnitGroup
@@ -118,8 +119,6 @@
118119
from . import maps
119120
from . import structure
120121
from . import number_field_morphisms
121-
from itertools import count
122-
from collections import Counter
123122

124123
from sage.categories.homset import Hom
125124
from sage.categories.sets_cat import Sets
@@ -128,6 +127,7 @@
128127
from sage.rings.real_mpfr import RR
129128

130129
from sage.interfaces.abc import GapElement
130+
from sage.rings.number_field.morphism import RelativeNumberFieldHomomorphism_from_abs
131131

132132
lazy_import('sage.libs.gap.element', 'GapElement', as_='LibGapElement')
133133
lazy_import('sage.rings.universal_cyclotomic_field', 'UniversalCyclotomicFieldElement')
@@ -136,13 +136,12 @@
136136
_NumberFields = NumberFields()
137137

138138

139-
from sage.rings.number_field.morphism import RelativeNumberFieldHomomorphism_from_abs
140-
141-
142139
def is_NumberFieldHomsetCodomain(codomain):
143140
"""
144141
Return whether ``codomain`` is a valid codomain for a number
145-
field homset. This is used by NumberField._Hom_ to determine
142+
field homset.
143+
144+
This is used by NumberField._Hom_ to determine
146145
whether the created homsets should be a
147146
:class:`sage.rings.number_field.homset.NumberFieldHomset`.
148147
@@ -414,8 +413,8 @@ def NumberField(polynomial, name=None, check=True, names=None, embedding=None,
414413
sage: RR(g)
415414
-1.25992104989487
416415
417-
If no embedding is specified or is complex, the comparison is not returning something
418-
meaningful.::
416+
If no embedding is specified or is complex, the comparison is not
417+
returning something meaningful. ::
419418
420419
sage: N.<g> = NumberField(x^3 + 2)
421420
sage: 1 < g

0 commit comments

Comments
 (0)