diff --git a/src/sage/libs/singular/ring.pyx b/src/sage/libs/singular/ring.pyx index 63b63070cd2..2f9ece4d055 100644 --- a/src/sage/libs/singular/ring.pyx +++ b/src/sage/libs/singular/ring.pyx @@ -31,7 +31,7 @@ from sage.libs.singular.decl cimport rDefault, GFInfo, ZnmInfo, nInitChar, AlgEx from sage.rings.integer cimport Integer from sage.rings.integer_ring cimport IntegerRing_class from sage.rings.integer_ring import ZZ -from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing +import sage.rings.abc from sage.rings.number_field.number_field_base cimport NumberField from sage.rings.rational_field import RationalField from sage.rings.finite_rings.finite_field_base import FiniteField as FiniteField_generic @@ -324,7 +324,7 @@ cdef ring *singular_ring_new(base_ring, n, names, term_order) except NULL: _ring = rDefault (_cf ,nvars, _names, nblcks, _order, _block0, _block1, _wvhdl) - elif is_IntegerModRing(base_ring): + elif isinstance(base_ring, sage.rings.abc.IntegerModRing): ch = base_ring.characteristic() if ch < 2: diff --git a/src/sage/matrix/matrix0.pyx b/src/sage/matrix/matrix0.pyx index 41b8da5f415..92c87e3a2ec 100644 --- a/src/sage/matrix/matrix0.pyx +++ b/src/sage/matrix/matrix0.pyx @@ -44,7 +44,7 @@ from sage.categories.integral_domains import IntegralDomains from sage.rings.ring cimport CommutativeRing from sage.rings.ring import is_Ring -from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing +import sage.rings.abc from sage.rings.integer_ring import is_IntegerRing import sage.modules.free_module @@ -5749,7 +5749,7 @@ cdef class Matrix(sage.structure.element.Matrix): R = self.base_ring() if algorithm is None and R in _Fields: return ~self - elif algorithm is None and is_IntegerModRing(R): + elif algorithm is None and isinstance(R, sage.rings.abc.IntegerModRing): # Finite fields are handled above. # This is "easy" in that we either get an error or # the right answer. Note that of course there diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index d4a8ec9d3a1..f94e77474c8 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -94,7 +94,7 @@ from sage.rings.complex_double import CDF from sage.rings.real_mpfr import RealField from sage.rings.complex_mpfr import ComplexField from sage.rings.finite_rings.integer_mod_ring import IntegerModRing -from sage.misc.derivative import multi_derivative +import sage.rings.abc from sage.arith.numerical_approx cimport digits_to_bits from copy import copy @@ -822,8 +822,7 @@ cdef class Matrix(Matrix1): if not K.is_integral_domain(): # The non-integral-domain case is handled almost entirely # separately. - from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing - if is_IntegerModRing(K): + if isinstance(K, sage.rings.abc.IntegerModRing): from sage.libs.pari import pari A = pari(self.lift()) b = pari(B).lift() @@ -1985,7 +1984,6 @@ cdef class Matrix(Matrix1): sage: A.determinant() == B.determinant() True """ - from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing from sage.symbolic.ring import is_SymbolicExpressionRing cdef Py_ssize_t n @@ -2031,7 +2029,7 @@ cdef class Matrix(Matrix1): return d # Special case for Z/nZ or GF(p): - if is_IntegerModRing(R) and self.is_dense(): + if isinstance(R, sage.rings.abc.IntegerModRing) and self.is_dense(): import sys # If the characteristic is prime and smaller than a machine # word, use PARI. @@ -14723,6 +14721,8 @@ cdef class Matrix(Matrix1): for i from 0 <= i < size: PyList_Append(M,f(PyList_GET_ITEM(L,i))) + from sage.rings.finite_rings.integer_mod_ring import IntegerModRing + return MatrixSpace(IntegerModRing(2), nrows=self._nrows,ncols=self._ncols).matrix(M) @@ -15123,6 +15123,7 @@ cdef class Matrix(Matrix1): sage: v.derivative(x,x) (0, 0, 2) """ + from sage.misc.derivative import multi_derivative return multi_derivative(self, args) def exp(self): diff --git a/src/sage/matrix/matrix_rational_dense.pyx b/src/sage/matrix/matrix_rational_dense.pyx index d67529c0a7e..3432de8c349 100644 --- a/src/sage/matrix/matrix_rational_dense.pyx +++ b/src/sage/matrix/matrix_rational_dense.pyx @@ -109,7 +109,7 @@ from sage.rings.integer cimport Integer from sage.rings.ring import is_Ring from sage.rings.integer_ring import ZZ, is_IntegerRing from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF -from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing +import sage.rings.abc from sage.rings.rational_field import QQ from sage.arith.all import gcd @@ -1487,7 +1487,7 @@ cdef class Matrix_rational_dense(Matrix_dense): return A from .matrix_modn_dense_double import MAX_MODULUS - if is_IntegerModRing(R) and R.order() < MAX_MODULUS: + if isinstance(R, sage.rings.abc.IntegerModRing) and R.order() < MAX_MODULUS: b = R.order() A, d = self._clear_denom() if not b.gcd(d).is_one(): diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index 47766db0c46..eabba820926 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -236,7 +236,7 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): except ImportError: pass - if sage.rings.finite_rings.integer_mod_ring.is_IntegerModRing(R): + if isinstance(R, sage.rings.abc.IntegerModRing): from . import matrix_modn_dense_double, matrix_modn_dense_float if R.order() < matrix_modn_dense_float.MAX_MODULUS: return matrix_modn_dense_float.Matrix_modn_dense_float @@ -326,7 +326,7 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): if implementation is not None: raise ValueError("cannot choose an implementation for sparse matrices") - if sage.rings.finite_rings.integer_mod_ring.is_IntegerModRing(R) and R.order() < matrix_modn_sparse.MAX_MODULUS: + if isinstance(R, sage.rings.abc.IntegerModRing) and R.order() < matrix_modn_sparse.MAX_MODULUS: return matrix_modn_sparse.Matrix_modn_sparse if sage.rings.rational_field.is_RationalField(R): diff --git a/src/sage/modules/free_module.py b/src/sage/modules/free_module.py index c28a31707a7..1e3c73da128 100644 --- a/src/sage/modules/free_module.py +++ b/src/sage/modules/free_module.py @@ -173,7 +173,7 @@ import sage.rings.abc import sage.rings.integer_ring import sage.rings.rational_field -import sage.rings.finite_rings.integer_mod_ring +import sage.rings.abc import sage.rings.infinity import sage.rings.integer from sage.categories.principal_ideal_domains import PrincipalIdealDomains @@ -254,7 +254,7 @@ def create_object(self, version, key): elif base_ring in PrincipalIdealDomains(): return FreeModule_ambient_pid(base_ring, rank, sparse=sparse) - elif isinstance(base_ring, sage.rings.number_field.order.Order) \ + elif isinstance(base_ring, sage.rings.abc.Order) \ and base_ring.is_maximal() and base_ring.class_number() == 1: return FreeModule_ambient_pid(base_ring, rank, sparse=sparse) @@ -7435,7 +7435,7 @@ def element_class(R, is_sparse): elif sage.rings.rational_field.is_RationalField(R) and not is_sparse: from .vector_rational_dense import Vector_rational_dense return Vector_rational_dense - elif sage.rings.finite_rings.integer_mod_ring.is_IntegerModRing(R) and not is_sparse: + elif isinstance(R, sage.rings.abc.IntegerModRing) and not is_sparse: from .vector_mod2_dense import Vector_mod2_dense if R.order() == 2: return Vector_mod2_dense diff --git a/src/sage/modules/free_module_element.pyx b/src/sage/modules/free_module_element.pyx index 2075d07c0ae..21d898c117c 100644 --- a/src/sage/modules/free_module_element.pyx +++ b/src/sage/modules/free_module_element.pyx @@ -123,7 +123,6 @@ from sage.rings.infinity import Infinity, AnInfinity from sage.rings.integer_ring import ZZ from sage.rings.real_double import RDF from sage.rings.complex_double import CDF -from sage.misc.derivative import multi_derivative from sage.rings.ring cimport Ring from sage.rings.integer cimport Integer, smallInteger @@ -3968,6 +3967,7 @@ cdef class FreeModuleElement(Vector): # abstract base class sage: v.derivative(x,x) (0, 0, 2) """ + from sage.misc.derivative import multi_derivative return multi_derivative(self, args) diff = derivative diff --git a/src/sage/modules/vector_space_morphism.py b/src/sage/modules/vector_space_morphism.py index 7c2104b1f17..1a1fde6eb5a 100644 --- a/src/sage/modules/vector_space_morphism.py +++ b/src/sage/modules/vector_space_morphism.py @@ -688,8 +688,10 @@ def linear_transformation(arg0, arg1=None, arg2=None, side='left'): from sage.modules.module import is_VectorSpace from sage.modules.free_module import VectorSpace from sage.categories.homset import Hom - from sage.symbolic.ring import SR - from sage.modules.vector_callable_symbolic_dense import Vector_callable_symbolic_dense + try: + from sage.modules.vector_callable_symbolic_dense import Vector_callable_symbolic_dense + except ImportError: + Vector_callable_symbolic_dense = () if not side in ['left', 'right']: raise ValueError("side must be 'left' or 'right', not {0}".format(side)) @@ -734,6 +736,7 @@ def linear_transformation(arg0, arg1=None, arg2=None, side='left'): elif isinstance(arg2, (list, tuple)): pass elif isinstance(arg2, Vector_callable_symbolic_dense): + from sage.symbolic.ring import SR args = arg2.parent().base_ring()._arguments exprs = arg2.change_ring(SR) m = len(args) diff --git a/src/sage/rings/abc.pyx b/src/sage/rings/abc.pyx index c65e03d9ed0..147dcb4f089 100644 --- a/src/sage/rings/abc.pyx +++ b/src/sage/rings/abc.pyx @@ -32,3 +32,18 @@ cdef class ComplexDoubleField(Field): """ pass + + +class IntegerModRing: + r""" + Abstract base class for :class:`~sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic`. + """ + + pass + +class Order: + r""" + Abstract base class for :class:`~sage.rings.number_field.order.Order`. + """ + + pass diff --git a/src/sage/rings/finite_rings/finite_field_base.pyx b/src/sage/rings/finite_rings/finite_field_base.pyx index 91f69730fee..f3183df44aa 100644 --- a/src/sage/rings/finite_rings/finite_field_base.pyx +++ b/src/sage/rings/finite_rings/finite_field_base.pyx @@ -40,6 +40,7 @@ from sage.misc.persist import register_unpickle_override from sage.misc.cachefunc import cached_method from sage.misc.prandom import randrange from sage.rings.integer cimport Integer +import sage.rings.abc from sage.misc.superseded import deprecation_cython as deprecation # Copied from sage.misc.fast_methods, used in __hash__() below. @@ -1342,10 +1343,9 @@ cdef class FiniteField(Field): False """ from sage.rings.integer_ring import ZZ - from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing if R is int or R is long or R is ZZ: return True - if is_IntegerModRing(R) and self.characteristic().divides(R.characteristic()): + if isinstance(R, sage.rings.abc.IntegerModRing) and self.characteristic().divides(R.characteristic()): return R.hom((self.one(),), check=False) if is_FiniteField(R): if R is self: diff --git a/src/sage/rings/finite_rings/integer_mod_ring.py b/src/sage/rings/finite_rings/integer_mod_ring.py index c704b2a2eb7..28fb2736491 100644 --- a/src/sage/rings/finite_rings/integer_mod_ring.py +++ b/src/sage/rings/finite_rings/integer_mod_ring.py @@ -64,6 +64,7 @@ from sage.arith.all import factor, primitive_root, CRT_basis import sage.rings.ring as ring +import sage.rings.abc from . import integer_mod import sage.rings.integer as integer import sage.rings.integer_ring as integer_ring @@ -243,11 +244,18 @@ def is_IntegerModRing(x): """ Return ``True`` if ``x`` is an integer modulo ring. + This function is deprecated. Use :func:`isinstance` with + :class:`sage.rings.abc.IntegerModRing` instead. + EXAMPLES:: sage: from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing sage: R = IntegerModRing(17) sage: is_IntegerModRing(R) + doctest:warning... + DeprecationWarning: the function is_IntegerModRing is deprecated. + Use isinstance(..., sage.rings.abc.IntegerModRing) instead. + See https://trac.sagemath.org/32606 for details. True sage: is_IntegerModRing(GF(13)) True @@ -258,6 +266,9 @@ def is_IntegerModRing(x): sage: is_IntegerModRing(ZZ) False """ + from sage.misc.superseded import deprecation + deprecation(32606, "the function is_IntegerModRing is deprecated. " + "Use isinstance(..., sage.rings.abc.IntegerModRing) instead.") return isinstance(x, IntegerModRing_generic) @@ -297,7 +308,7 @@ def _unit_gens_primepowercase(p, r): @richcmp_method -class IntegerModRing_generic(quotient_ring.QuotientRing_generic): +class IntegerModRing_generic(quotient_ring.QuotientRing_generic, sage.rings.abc.IntegerModRing): """ The ring of integers modulo `N`. diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py index 56ef3d550bb..ec128df7834 100644 --- a/src/sage/rings/number_field/order.py +++ b/src/sage/rings/number_field/order.py @@ -47,6 +47,7 @@ from sage.rings.ring import IntegralDomain from sage.structure.sequence import Sequence from sage.rings.integer_ring import ZZ +import sage.rings.abc from sage.structure.element import is_Element from .number_field_element import OrderElement_absolute, OrderElement_relative @@ -126,7 +127,7 @@ def EquationOrder(f, names, **kwds): return K.order(K.gens()) -class Order(IntegralDomain): +class Order(IntegralDomain, sage.rings.abc.Order): r""" An order in a number field. diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index da88a329bc6..65e5e7ee7a1 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -249,6 +249,7 @@ from sage.misc.method_decorator import MethodDecorator from sage.rings.integer_ring import ZZ +import sage.rings.abc import sage.rings.polynomial.toy_buchberger as toy_buchberger import sage.rings.polynomial.toy_variety as toy_variety import sage.rings.polynomial.toy_d_basis as toy_d_basis @@ -4288,7 +4289,6 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal sage: I.groebner_basis('magma:GroebnerBasis') # optional - magma [a + (-60)*c^3 + 158/7*c^2 + 8/7*c - 1, b + 30*c^3 + (-79/7)*c^2 + 3/7*c, c^4 + (-10/21)*c^3 + 1/84*c^2 + 1/84*c] """ - from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing @@ -4331,7 +4331,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal deg_bound=deg_bound, mult_bound=mult_bound, prot=prot, *args, **kwds)] elif (R.term_order().is_global() - and is_IntegerModRing(B) + and isinstance(B, sage.rings.abc.IntegerModRing) and not B.is_field()): verbose("Warning: falling back to very slow toy implementation.", level=0) diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx index 03f8015f7ea..6736f7a09c1 100644 --- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx @@ -221,6 +221,7 @@ from sage.rings.polynomial.polydict cimport ETuple from sage.rings.polynomial.polynomial_ring import is_PolynomialRing # base ring imports +import sage.rings.abc from sage.rings.finite_rings.finite_field_prime_modn import FiniteField_prime_modn from sage.rings.rational cimport Rational from sage.rings.rational_field import QQ @@ -228,7 +229,6 @@ import sage.rings.abc from sage.rings.integer_ring import is_IntegerRing, ZZ from sage.rings.integer cimport Integer from sage.rings.integer import GCD_list -from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing from sage.rings.number_field.number_field_base cimport NumberField from sage.structure.element import coerce_binop @@ -1406,7 +1406,7 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_base): elif is_IntegerRing(base_ring): self.__singular = singular.ring("(integer)", _vars, order=order) - elif is_IntegerModRing(base_ring): + elif isinstance(base_ring, sage.rings.abc.IntegerModRing): ch = base_ring.characteristic() if ch.is_power_of(2): exp = ch.nbits() -1 diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index f7807221d55..1e948372613 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -101,7 +101,6 @@ from sage.structure.element cimport (parent, have_same_parent, from sage.rings.rational_field import QQ, is_RationalField from sage.rings.integer_ring import ZZ, is_IntegerRing -from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing from sage.rings.integer cimport Integer, smallInteger from sage.libs.gmp.mpz cimport * from sage.rings.fraction_field import is_FractionField @@ -4446,7 +4445,7 @@ cdef class Polynomial(CommutativeAlgebraElement): n = None - if is_IntegerModRing(R) or is_IntegerRing(R): + if isinstance(R, sage.rings.abc.IntegerModRing) or is_IntegerRing(R): try: G = list(self._pari_with_name().factor()) except PariError: @@ -8124,7 +8123,7 @@ cdef class Polynomial(CommutativeAlgebraElement): if K.is_finite(): if multiplicities: raise NotImplementedError("root finding with multiplicities for this polynomial not implemented (try the multiplicities=False option)") - elif is_IntegerModRing(K): + elif isinstance(K, sage.rings.abc.IntegerModRing): # handling via the chinese remainders theorem N = K.cardinality() primes = N.prime_divisors() diff --git a/src/sage/rings/polynomial/polynomial_ring_constructor.py b/src/sage/rings/polynomial/polynomial_ring_constructor.py index c88f6705ccd..603bdaff2ec 100644 --- a/src/sage/rings/polynomial/polynomial_ring_constructor.py +++ b/src/sage/rings/polynomial/polynomial_ring_constructor.py @@ -27,9 +27,9 @@ import sage.rings.ring as ring import sage.rings.padics.padic_base_leaves as padic_base_leaves +import sage.rings.abc from sage.rings.integer import Integer from sage.rings.finite_rings.finite_field_base import is_FiniteField -from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing from sage.misc.cachefunc import weak_cached_function @@ -694,7 +694,7 @@ def _single_variate(base_ring, name, sparse=None, implementation=None, order=Non # Specialized implementations specialized = None - if is_IntegerModRing(base_ring): + if isinstance(base_ring, sage.rings.abc.IntegerModRing): n = base_ring.order() if n.is_prime(): specialized = polynomial_ring.PolynomialRing_dense_mod_p diff --git a/src/sage/rings/polynomial/polynomial_singular_interface.py b/src/sage/rings/polynomial/polynomial_singular_interface.py index 2fd1ac24b2b..b0e067f1f78 100644 --- a/src/sage/rings/polynomial/polynomial_singular_interface.py +++ b/src/sage/rings/polynomial/polynomial_singular_interface.py @@ -38,11 +38,10 @@ ###################################################################### import sage.rings.fraction_field +import sage.rings.abc import sage.rings.number_field as number_field from sage.interfaces.all import singular -import sage.rings.abc -from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing from sage.rings.rational_field import is_RationalField from sage.rings.function_field.function_field import RationalFunctionField from sage.rings.finite_rings.finite_field_base import is_FiniteField @@ -333,7 +332,7 @@ def _singular_init_(self, singular=singular): gen = str(base_ring.gen()) self.__singular = singular.ring( "(%s,%s)"%(base_ring.characteristic(),gen), _vars, order=order, check=False) - elif is_IntegerModRing(base_ring): + elif isinstance(base_ring, sage.rings.abc.IntegerModRing): ch = base_ring.characteristic() if ch.is_power_of(2): exp = ch.nbits() -1 @@ -387,7 +386,8 @@ def can_convert_to_singular(R): or is_RationalField(base_ring) or is_IntegerModRing(base_ring) or isinstance(base_ring, (sage.rings.abc.RealField, sage.rings.abc.ComplexField, - sage.rings.abc.RealDoubleField, sage.rings.abc.ComplexDoubleField))): + sage.rings.abc.RealDoubleField, sage.rings.abc.ComplexDoubleField, + sage.rings.abc.IntegerModRing))): return True elif base_ring.is_prime_field(): return base_ring.characteristic() <= 2147483647 diff --git a/src/sage/schemes/elliptic_curves/constructor.py b/src/sage/schemes/elliptic_curves/constructor.py index e9320cc174b..90bc4519082 100644 --- a/src/sage/schemes/elliptic_curves/constructor.py +++ b/src/sage/schemes/elliptic_curves/constructor.py @@ -25,7 +25,7 @@ import sage.rings.all as rings -from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing +import sage.rings.abc from sage.rings.polynomial.multi_polynomial_ring import is_MPolynomialRing from sage.rings.finite_rings.finite_field_constructor import is_FiniteField from sage.rings.number_field.number_field import is_NumberField @@ -464,7 +464,7 @@ def create_object(self, version, key, **kwds): elif rings.is_pAdicField(R): from .ell_padic_field import EllipticCurve_padic_field return EllipticCurve_padic_field(R, x) - elif is_FiniteField(R) or (is_IntegerModRing(R) and R.characteristic().is_prime()): + elif is_FiniteField(R) or (isinstance(R, sage.rings.abc.IntegerModRing) and R.characteristic().is_prime()): from .ell_finite_field import EllipticCurve_finite_field return EllipticCurve_finite_field(R, x) elif R in _Fields: diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py index 912496bca28..b5207f513f0 100644 --- a/src/sage/schemes/elliptic_curves/ell_generic.py +++ b/src/sage/schemes/elliptic_curves/ell_generic.py @@ -46,6 +46,7 @@ import math +import sage.rings.abc from sage.rings.all import PolynomialRing from sage.rings.polynomial.polynomial_ring import polygen, polygens import sage.groups.additive_abelian.additive_abelian_group as groups @@ -156,8 +157,7 @@ def __init__(self, K, ainvs): # EllipticCurvePoint_finite_field for finite rings, so that we # can do some arithmetic on points over Z/NZ, for teaching # purposes. - from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing - if is_IntegerModRing(K): + if isinstance(K, sage.rings.abc.IntegerModRing): self._point = ell_point.EllipticCurvePoint_finite_field _point = ell_point.EllipticCurvePoint diff --git a/src/sage/structure/parent.pyx b/src/sage/structure/parent.pyx index 4559972c94f..9d7527b913a 100644 --- a/src/sage/structure/parent.pyx +++ b/src/sage/structure/parent.pyx @@ -2642,8 +2642,8 @@ cdef class Parent(sage.structure.category_object.CategoryObject): elif self_on_left and op is operator.pow: S_is_int = parent_is_integers(S) if not S_is_int: - from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing - if is_IntegerModRing(S): + from sage.rings.abc import IntegerModRing + if isinstance(S, IntegerModRing): # We allow powering by an IntegerMod by treating it # as an integer. # diff --git a/src/sage/symbolic/ring.pyx b/src/sage/symbolic/ring.pyx index ffe8d7443f2..9bc5c1db7a1 100644 --- a/src/sage/symbolic/ring.pyx +++ b/src/sage/symbolic/ring.pyx @@ -47,6 +47,7 @@ from sage.structure.element cimport Element from sage.categories.morphism cimport Morphism from sage.structure.coerce cimport is_numpy_type +import sage.rings.abc from sage.rings.integer_ring import ZZ # is_SymbolicVariable used to be defined here; re-export it @@ -205,7 +206,6 @@ cdef class SymbolicRing(CommutativeRing): from sage.rings.real_mpfr import mpfr_prec_min from sage.rings.fraction_field import is_FractionField - from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing from sage.rings.real_mpfi import is_RealIntervalField from sage.rings.complex_interval_field import is_ComplexIntervalField from sage.rings.real_arb import RealBallField @@ -234,7 +234,7 @@ cdef class SymbolicRing(CommutativeRing): or is_RealIntervalField(R) or is_ComplexIntervalField(R) or isinstance(R, RealBallField) or isinstance(R, ComplexBallField) - or is_IntegerModRing(R) or is_FiniteField(R)): + or isinstance(R, sage.rings.abc.IntegerModRing) or is_FiniteField(R)): return True elif isinstance(R, GenericSymbolicSubring): return True