Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Replace all uses of is_IntegerModRing by isinstance(..., sage.rings.a…
Browse files Browse the repository at this point in the history
…bc.IntegerModRing)
  • Loading branch information
Matthias Koeppe committed Oct 1, 2021
1 parent 8ef2b35 commit 335cd3e
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/sage/libs/singular/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matrix/matrix_rational_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/multi_polynomial_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -229,7 +230,6 @@ from sage.rings.real_mpfr import is_RealField
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
Expand Down Expand Up @@ -1407,7 +1407,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
Expand Down
5 changes: 2 additions & 3 deletions src/sage/rings/polynomial/polynomial_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/polynomial_ring_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/sage/rings/polynomial/polynomial_singular_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
######################################################################

import sage.rings.fraction_field
import sage.rings.abc
import sage.rings.number_field as number_field

from sage.interfaces.all import singular
from sage.rings.complex_mpfr import is_ComplexField
from sage.rings.real_mpfr import is_RealField
from sage.rings.complex_double import is_ComplexDoubleField
from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing
from sage.rings.real_double import is_RealDoubleField
from sage.rings.rational_field import is_RationalField
from sage.rings.function_field.function_field import RationalFunctionField
Expand Down Expand Up @@ -336,7 +336,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
Expand Down Expand Up @@ -388,7 +388,7 @@ def can_convert_to_singular(R):
if (base_ring is ZZ
or sage.rings.finite_rings.finite_field_constructor.is_FiniteField(base_ring)
or is_RationalField(base_ring)
or is_IntegerModRing(base_ring)
or isinstance(base_ring, sage.rings.abc.IntegerModRing)
or is_RealField(base_ring)
or is_ComplexField(base_ring)
or is_RealDoubleField(base_ring)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/schemes/elliptic_curves/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/schemes/elliptic_curves/ell_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/sage/symbolic/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 335cd3e

Please sign in to comment.