diff --git a/src/sage/rings/abc.pxd b/src/sage/rings/abc.pxd index a53b512d62f..a2d2e3f0ce4 100644 --- a/src/sage/rings/abc.pxd +++ b/src/sage/rings/abc.pxd @@ -1,4 +1,4 @@ -from .ring cimport CommutativeRing, Field +from sage.rings.ring cimport CommutativeRing, Field cdef class RealField(Field): diff --git a/src/sage/rings/all.py b/src/sage/rings/all.py index 1d7b89601f5..2c2f6a0523e 100644 --- a/src/sage/rings/all.py +++ b/src/sage/rings/all.py @@ -12,10 +12,10 @@ # **************************************************************************** from sage.misc.lazy_import import lazy_import -from .all__sagemath_categories import * +from sage.rings.all__sagemath_categories import * # Ring base classes -from .ring import (Ring, Field, CommutativeRing, IntegralDomain, +from sage.rings.ring import (Ring, Field, CommutativeRing, IntegralDomain, DedekindDomain, PrincipalIdealDomain, EuclideanDomain) # Ring element base classes @@ -25,22 +25,22 @@ EuclideanDomainElement, FieldElement) # Ideals -from .ideal import Ideal +from sage.rings.ideal import Ideal ideal = Ideal # Quotient -from .quotient_ring import QuotientRing +from sage.rings.quotient_ring import QuotientRing # Infinities -from .infinity import infinity, Infinity, InfinityRing, unsigned_infinity, UnsignedInfinityRing +from sage.rings.infinity import infinity, Infinity, InfinityRing, unsigned_infinity, UnsignedInfinityRing # Rational integers. -from .integer_ring import IntegerRing, ZZ, crt_basis -from .integer import Integer +from sage.rings.integer_ring import IntegerRing, ZZ, crt_basis +from sage.rings.integer import Integer # Rational numbers -from .rational_field import RationalField, QQ -from .rational import Rational +from sage.rings.rational_field import RationalField, QQ +from sage.rings.rational import Rational Rationals = RationalField # Integers modulo n. @@ -49,120 +49,120 @@ Integers = IntegerModRing # Finite fields -from .finite_rings.all import * +from sage.rings.finite_rings.all import * # Number field -from .number_field.all import * +from sage.rings.number_field.all import * # Function field -from .function_field.all import * +from sage.rings.function_field.all import * # Finite residue fields -from .finite_rings.residue_field import ResidueField +from sage.rings.finite_rings.residue_field import ResidueField # p-adic field -from .padics.all import * -from .padics.padic_printing import _printer_defaults as padic_printing +from sage.rings.padics.all import * +from sage.rings.padics.padic_printing import _printer_defaults as padic_printing # valuations -from .valuation.all import * +from sage.rings.valuation.all import * # Semirings -from .semirings.all import * +from sage.rings.semirings.all import * # Real numbers -from .real_mpfr import (RealField, RR, +from sage.rings.real_mpfr import (RealField, RR, create_RealNumber as RealNumber) # this is used by the preparser to wrap real literals -- very important. Reals = RealField -from .real_double import RealDoubleField, RDF, RealDoubleElement +from sage.rings.real_double import RealDoubleField, RDF, RealDoubleElement -from .real_lazy import RealLazyField, RLF, ComplexLazyField, CLF +from sage.rings.real_lazy import RealLazyField, RLF, ComplexLazyField, CLF from sage.rings.real_arb import RealBallField, RBF # Polynomial Rings and Polynomial Quotient Rings -from .polynomial.all import * +from sage.rings.polynomial.all import * # Algebraic numbers -from .qqbar import (AlgebraicRealField, AA, +from sage.rings.qqbar import (AlgebraicRealField, AA, AlgebraicReal, AlgebraicField, QQbar, AlgebraicNumber, number_field_elements_from_algebraics) -from .universal_cyclotomic_field import UniversalCyclotomicField, E +from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField, E # Intervals -from .real_mpfi import (RealIntervalField, +from sage.rings.real_mpfi import (RealIntervalField, RIF, RealInterval) # Complex numbers -from .complex_mpfr import ComplexField -from .complex_mpfr import create_ComplexNumber as ComplexNumber +from sage.rings.complex_mpfr import ComplexField +from sage.rings.complex_mpfr import create_ComplexNumber as ComplexNumber Complexes = ComplexField -from .complex_interval_field import ComplexIntervalField -from .complex_interval import (create_ComplexIntervalFieldElement as ComplexIntervalFieldElement) +from sage.rings.complex_interval_field import ComplexIntervalField +from sage.rings.complex_interval import (create_ComplexIntervalFieldElement as ComplexIntervalFieldElement) -from .complex_double import ComplexDoubleField, ComplexDoubleElement, CDF +from sage.rings.complex_double import ComplexDoubleField, ComplexDoubleElement, CDF -from .complex_mpc import MPComplexField +from sage.rings.complex_mpc import MPComplexField from sage.rings.complex_arb import ComplexBallField, CBF lazy_import("sage.rings.imaginary_unit", "I") # Power series rings -from .power_series_ring import PowerSeriesRing +from sage.rings.power_series_ring import PowerSeriesRing # Laurent series ring in one variable -from .laurent_series_ring import LaurentSeriesRing +from sage.rings.laurent_series_ring import LaurentSeriesRing # Lazy Laurent series ring lazy_import('sage.rings.lazy_series_ring', ['LazyLaurentSeriesRing', 'LazyPowerSeriesRing', 'LazySymmetricFunctions', 'LazyDirichletSeriesRing']) # Tate algebras -from .tate_algebra import TateAlgebra +from sage.rings.tate_algebra import TateAlgebra # Puiseux series ring -from .puiseux_series_ring import PuiseuxSeriesRing +from sage.rings.puiseux_series_ring import PuiseuxSeriesRing # Pseudo-ring of PARI objects. -from .pari_ring import PariRing, Pari +from sage.rings.pari_ring import PariRing, Pari # Big-oh notation -from .big_oh import O +from sage.rings.big_oh import O # Fraction field -from .fraction_field import FractionField +from sage.rings.fraction_field import FractionField Frac = FractionField # Localization -from .localization import Localization +from sage.rings.localization import Localization # c-finite sequences -from .cfinite_sequence import CFiniteSequence, CFiniteSequences +from sage.rings.cfinite_sequence import CFiniteSequence, CFiniteSequences -from .bernoulli_mod_p import bernoulli_mod_p, bernoulli_mod_p_single +from sage.rings.bernoulli_mod_p import bernoulli_mod_p, bernoulli_mod_p_single -from .monomials import monomials +from sage.rings.monomials import monomials -from .cc import CC -from .cif import CIF +from sage.rings.cc import CC +from sage.rings.cif import CIF # invariant theory -from .invariants.all import * +from sage.rings.invariants.all import * -from .fast_arith import prime_range +from sage.rings.fast_arith import prime_range # continued fractions from sage.rings.continued_fraction import (continued_fraction, continued_fraction_list) # asymptotic ring -from .asymptotic.all import * +from sage.rings.asymptotic.all import * # Register classes in numbers abc -from . import numbers_abc +from sage.rings import numbers_abc diff --git a/src/sage/rings/all__sagemath_categories.py b/src/sage/rings/all__sagemath_categories.py index 8d14e7afcda..d03d1c6b483 100644 --- a/src/sage/rings/all__sagemath_categories.py +++ b/src/sage/rings/all__sagemath_categories.py @@ -1,6 +1,6 @@ # Ring base classes -from .ring import Ring - +from sage.rings.ring import Ring # Ideals -from .ideal import Ideal +from sage.rings.ideal import Ideal + ideal = Ideal diff --git a/src/sage/rings/big_oh.py b/src/sage/rings/big_oh.py index e9b22e77b37..917c81e0a3d 100644 --- a/src/sage/rings/big_oh.py +++ b/src/sage/rings/big_oh.py @@ -11,6 +11,7 @@ from sage.arith.misc import factor from sage.misc.lazy_import import lazy_import + lazy_import('sage.rings.padics.factory', ['Qp', 'Zp']) lazy_import('sage.rings.padics.padic_generic_element', 'pAdicGenericElement') from sage.rings.polynomial.polynomial_element import Polynomial @@ -25,10 +26,12 @@ except ImportError: PuiseuxSeries = () -from . import power_series_ring_element -from . import integer -from . import rational -from . import multi_power_series_ring_element +from sage.rings import ( + integer, + multi_power_series_ring_element, + power_series_ring_element, + rational, +) def O(*x, **kwds): diff --git a/src/sage/rings/cc.py b/src/sage/rings/cc.py index 6db89579029..94e3093488b 100644 --- a/src/sage/rings/cc.py +++ b/src/sage/rings/cc.py @@ -1,3 +1,3 @@ -from .complex_mpfr import ComplexField +from sage.rings.complex_mpfr import ComplexField CC = ComplexField() diff --git a/src/sage/rings/cif.py b/src/sage/rings/cif.py index 91924f4d26c..900c635e87b 100644 --- a/src/sage/rings/cif.py +++ b/src/sage/rings/cif.py @@ -1,3 +1,3 @@ -from .complex_interval_field import ComplexIntervalField +from sage.rings.complex_interval_field import ComplexIntervalField CIF = ComplexIntervalField() diff --git a/src/sage/rings/complex_conversion.pyx b/src/sage/rings/complex_conversion.pyx index e7e53724f9c..39c8b63eb55 100644 --- a/src/sage/rings/complex_conversion.pyx +++ b/src/sage/rings/complex_conversion.pyx @@ -1,5 +1,5 @@ -from .complex_double cimport ComplexDoubleElement -from .complex_mpfr cimport ComplexNumber +from sage.rings.complex_double cimport ComplexDoubleElement +from sage.rings.complex_mpfr cimport ComplexNumber from sage.libs.mpfr cimport mpfr_get_d, MPFR_RNDN from sage.libs.gsl.complex cimport GSL_SET_COMPLEX diff --git a/src/sage/rings/complex_double.pyx b/src/sage/rings/complex_double.pyx index 8f1e8205817..944bcc5aa27 100644 --- a/src/sage/rings/complex_double.pyx +++ b/src/sage/rings/complex_double.pyx @@ -105,10 +105,10 @@ complex_double_element_gamma = None complex_double_element_gamma_inc = None complex_double_element_zeta = None -from .complex_conversion cimport CCtoCDF +from sage.rings.complex_conversion cimport CCtoCDF -from .real_double cimport RealDoubleElement, double_repr -from .real_double import RDF +from sage.rings.real_double cimport RealDoubleElement, double_repr +from sage.rings.real_double import RDF from sage.rings.integer_ring import ZZ from sage.structure.richcmp cimport rich_to_bool diff --git a/src/sage/rings/complex_interval.pxd b/src/sage/rings/complex_interval.pxd index 56513b65747..60d8c010cd8 100644 --- a/src/sage/rings/complex_interval.pxd +++ b/src/sage/rings/complex_interval.pxd @@ -2,7 +2,7 @@ from sage.libs.mpfr.types cimport mpfr_prec_t from sage.libs.mpfi.types cimport mpfi_t cimport sage.structure.element -from .real_mpfi cimport RealIntervalFieldElement, RealIntervalField_class +from sage.rings.real_mpfi cimport RealIntervalFieldElement, RealIntervalField_class cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement): diff --git a/src/sage/rings/complex_interval.pyx b/src/sage/rings/complex_interval.pyx index c38261d136d..5b7a04fef10 100644 --- a/src/sage/rings/complex_interval.pyx +++ b/src/sage/rings/complex_interval.pyx @@ -66,12 +66,12 @@ from sage.arith.constants cimport LOG_TEN_TWO_PLUS_EPSILON from sage.structure.element cimport FieldElement from sage.structure.parent cimport Parent -from .complex_mpfr cimport ComplexNumber +from sage.rings.complex_mpfr cimport ComplexNumber from sage.rings.integer cimport Integer cimport sage.rings.real_mpfi as real_mpfi -from .real_mpfr cimport RealNumber -from .convert.mpfi cimport mpfi_set_sage -from .infinity import infinity +from sage.rings.real_mpfr cimport RealNumber +from sage.rings.convert.mpfi cimport mpfi_set_sage +from sage.rings.infinity import infinity def is_ComplexIntervalFieldElement(x): diff --git a/src/sage/rings/complex_interval_field.py b/src/sage/rings/complex_interval_field.py index 7903ab42bae..c2524923459 100644 --- a/src/sage/rings/complex_interval_field.py +++ b/src/sage/rings/complex_interval_field.py @@ -36,18 +36,17 @@ # **************************************************************************** -from sage.structure.parent import Parent -from .integer_ring import ZZ -from .rational_field import QQ -from .ring import Field -import sage.rings.abc -from . import integer -from . import complex_interval import weakref -from .real_mpfi import RealIntervalField, RealIntervalField_class -from .complex_mpfr import ComplexField -from sage.misc.cachefunc import cached_method +import sage.rings.abc +from sage.misc.cachefunc import cached_method +from sage.rings import complex_interval, integer +from sage.rings.complex_mpfr import ComplexField +from sage.rings.integer_ring import ZZ +from sage.rings.rational_field import QQ +from sage.rings.real_mpfi import RealIntervalField, RealIntervalField_class +from sage.rings.ring import Field +from sage.structure.parent import Parent cache = {} def ComplexIntervalField(prec=53, names=None): diff --git a/src/sage/rings/complex_mpc.pyx b/src/sage/rings/complex_mpc.pyx index 562286db44e..7a9ab37e268 100644 --- a/src/sage/rings/complex_mpc.pyx +++ b/src/sage/rings/complex_mpc.pyx @@ -59,7 +59,7 @@ EXAMPLES:: # **************************************************************************** import re -from . import real_mpfr +from sage.rings import real_mpfr import weakref from cpython.object cimport Py_NE @@ -74,13 +74,13 @@ from sage.structure.richcmp cimport rich_to_bool from sage.categories.map cimport Map from sage.libs.pari.all import pari -from .integer cimport Integer -from .complex_mpfr cimport ComplexNumber -from .complex_mpfr import ComplexField_class +from sage.rings.integer cimport Integer +from sage.rings.complex_mpfr cimport ComplexNumber +from sage.rings.complex_mpfr import ComplexField_class from sage.misc.randstate cimport randstate, current_randstate -from .real_mpfr cimport RealField_class, RealNumber -from .real_mpfr import mpfr_prec_min, mpfr_prec_max +from sage.rings.real_mpfr cimport RealField_class, RealNumber +from sage.rings.real_mpfr import mpfr_prec_min, mpfr_prec_max from sage.structure.richcmp cimport rich_to_bool, richcmp from sage.categories.fields import Fields diff --git a/src/sage/rings/complex_mpfr.pxd b/src/sage/rings/complex_mpfr.pxd index 4aa6de62a69..95972c52bb5 100644 --- a/src/sage/rings/complex_mpfr.pxd +++ b/src/sage/rings/complex_mpfr.pxd @@ -1,7 +1,7 @@ from sage.libs.mpfr.types cimport mpfr_t, mpfr_prec_t cimport sage.structure.element -from .real_mpfr cimport RealNumber +from sage.rings.real_mpfr cimport RealNumber cdef class ComplexNumber(sage.structure.element.FieldElement): cdef mpfr_t __re diff --git a/src/sage/rings/complex_mpfr.pyx b/src/sage/rings/complex_mpfr.pyx index d6f92bb2fee..c8a27ac7aec 100644 --- a/src/sage/rings/complex_mpfr.pyx +++ b/src/sage/rings/complex_mpfr.pyx @@ -46,11 +46,11 @@ from sage.misc.sage_eval import sage_eval import sage.rings.abc from sage.arith.constants cimport LOG_TEN_TWO_PLUS_EPSILON -from . import infinity -from .integer cimport Integer +from sage.rings import infinity +from sage.rings.integer cimport Integer -from .complex_double cimport ComplexDoubleElement -from .real_mpfr cimport RealNumber +from sage.rings.complex_double cimport ComplexDoubleElement +from sage.rings.real_mpfr cimport RealNumber from sage.libs.gsl.complex cimport * from sage.libs.mpmath.utils cimport mpfr_to_mpfval diff --git a/src/sage/rings/continued_fraction.py b/src/sage/rings/continued_fraction.py index 1980d55b27c..a813816ac50 100644 --- a/src/sage/rings/continued_fraction.py +++ b/src/sage/rings/continued_fraction.py @@ -207,12 +207,12 @@ import numbers -from sage.structure.sage_object import SageObject -from sage.structure.richcmp import richcmp_method, rich_to_bool import sage.rings.abc -from .integer import Integer -from .integer_ring import ZZ -from .infinity import Infinity +from sage.rings.infinity import Infinity +from sage.rings.integer import Integer +from sage.rings.integer_ring import ZZ +from sage.structure.richcmp import rich_to_bool, richcmp_method +from sage.structure.sage_object import SageObject ZZ_0 = Integer(0) ZZ_1 = Integer(1) @@ -849,8 +849,9 @@ def convergents(self): Add an example with infinite list. """ if self.length() == Infinity: - from sage.misc.lazy_list import lazy_list from itertools import count + + from sage.misc.lazy_list import lazy_list return lazy_list(self.numerator(n) / self.denominator(n) for n in count()) return [self.numerator(n) / self.denominator(n) @@ -876,8 +877,9 @@ def quotients(self): Add an example with infinite list. """ if self.length() == Infinity: - from sage.misc.lazy_list import lazy_list from itertools import count + + from sage.misc.lazy_list import lazy_list return lazy_list(self.quotient(n) for n in count()) return [self.quotient(n) for n in range(len(self))] @@ -1147,8 +1149,7 @@ def numerical_approx(self, prec=None, digits=None, algorithm=None): sage: cf.n(digits=33) # needs sage.combinat 1.28102513329556981555293038097590 """ - from sage.arith.numerical_approx import (digits_to_bits, - numerical_approx_generic) + from sage.arith.numerical_approx import digits_to_bits, numerical_approx_generic if prec is None: prec = digits_to_bits(digits) return numerical_approx_generic(self, prec) @@ -1564,8 +1565,8 @@ def value(self): # now x is one of the root of the equation # q1 x^2 + (q0 - p1) x - p0 = 0 - from sage.rings.number_field.number_field import QuadraticField from sage.misc.functional import squarefree_part + from sage.rings.number_field.number_field import QuadraticField D = (q0-p1)**2 + 4*q1*p0 DD = squarefree_part(D) Q = QuadraticField(DD, 'sqrt%d' % DD) @@ -2674,8 +2675,8 @@ def continued_fraction(x, value=None): return ContinuedFraction_periodic(x1, x2) # input for infinite partial quotient expansion - from sage.misc.lazy_list import lazy_list_generic from sage.combinat.words.infinite_word import InfiniteWord_class + from sage.misc.lazy_list import lazy_list_generic if isinstance(x, (lazy_list_generic, InfiniteWord_class)): return ContinuedFraction_infinite(x, value) diff --git a/src/sage/rings/convert/mpfi.pyx b/src/sage/rings/convert/mpfi.pyx index abef4963bcf..0d42927740a 100644 --- a/src/sage/rings/convert/mpfi.pyx +++ b/src/sage/rings/convert/mpfi.pyx @@ -23,14 +23,14 @@ from sage.cpython.string cimport bytes_to_str from sage.structure.element cimport Element import sage.rings.abc -from ..integer cimport Integer -from ..rational cimport Rational -from ..real_mpfi cimport RealIntervalFieldElement, RealIntervalField_class -from ..real_mpfr cimport RealNumber -from ..real_double cimport RealDoubleElement -from ..complex_mpfr cimport ComplexNumber -from ..complex_interval cimport ComplexIntervalFieldElement -from ..complex_double cimport ComplexDoubleElement +from sage.rings.integer cimport Integer +from sage.rings.rational cimport Rational +from sage.rings.real_mpfi cimport RealIntervalFieldElement, RealIntervalField_class +from sage.rings.real_mpfr cimport RealNumber +from sage.rings.real_double cimport RealDoubleElement +from sage.rings.complex_mpfr cimport ComplexNumber +from sage.rings.complex_interval cimport ComplexIntervalFieldElement +from sage.rings.complex_double cimport ComplexDoubleElement from cypari2.gen cimport Gen diff --git a/src/sage/rings/finite_rings/element_givaro.pyx b/src/sage/rings/finite_rings/element_givaro.pyx index 0483b4949e7..7619ec7185f 100644 --- a/src/sage/rings/finite_rings/element_givaro.pyx +++ b/src/sage/rings/finite_rings/element_givaro.pyx @@ -57,7 +57,7 @@ from cysignals.signals cimport sig_on, sig_off from cypari2.paridecl cimport * from sage.misc.randstate cimport current_randstate -from .element_pari_ffelt cimport FiniteFieldElement_pari_ffelt +from sage.rings.finite_rings.element_pari_ffelt cimport FiniteFieldElement_pari_ffelt from sage.structure.richcmp cimport richcmp import sage.arith.all diff --git a/src/sage/rings/finite_rings/element_ntl_gf2e.pyx b/src/sage/rings/finite_rings/element_ntl_gf2e.pyx index 61e7b05048c..60d275ea5ae 100644 --- a/src/sage/rings/finite_rings/element_ntl_gf2e.pyx +++ b/src/sage/rings/finite_rings/element_ntl_gf2e.pyx @@ -44,8 +44,8 @@ from sage.libs.pari.all import pari from cypari2.gen cimport Gen from cypari2.stack cimport clear_stack -from .element_pari_ffelt import FiniteFieldElement_pari_ffelt -from .finite_field_ntl_gf2e import FiniteField_ntl_gf2e +from sage.rings.finite_rings.element_pari_ffelt import FiniteFieldElement_pari_ffelt +from sage.rings.finite_rings.finite_field_ntl_gf2e import FiniteField_ntl_gf2e from sage.interfaces.abc import GapElement diff --git a/src/sage/rings/finite_rings/element_pari_ffelt.pyx b/src/sage/rings/finite_rings/element_pari_ffelt.pyx index 9beb505cae3..ca262f6f668 100644 --- a/src/sage/rings/finite_rings/element_pari_ffelt.pyx +++ b/src/sage/rings/finite_rings/element_pari_ffelt.pyx @@ -24,8 +24,8 @@ from sage.libs.pari.convert_gmp cimport _new_GEN_from_mpz_t from cypari2.stack cimport new_gen, new_gen_noclear, clear_stack from cypari2.gen cimport Gen as pari_gen, objtogen -from .element_base cimport FinitePolyExtElement -from .integer_mod import IntegerMod_abstract +from sage.rings.finite_rings.element_base cimport FinitePolyExtElement +from sage.rings.finite_rings.integer_mod import IntegerMod_abstract import sage.rings.integer from sage.rings.integer cimport Integer diff --git a/src/sage/rings/finite_rings/hom_finite_field_givaro.pxd b/src/sage/rings/finite_rings/hom_finite_field_givaro.pxd index 62898386212..f5a70c975f9 100644 --- a/src/sage/rings/finite_rings/hom_finite_field_givaro.pxd +++ b/src/sage/rings/finite_rings/hom_finite_field_givaro.pxd @@ -1,8 +1,8 @@ -from .hom_finite_field cimport (SectionFiniteFieldHomomorphism_generic, +from sage.rings.finite_rings.hom_finite_field cimport (SectionFiniteFieldHomomorphism_generic, FiniteFieldHomomorphism_generic, FrobeniusEndomorphism_finite_field) from sage.structure.element cimport Element -from .element_givaro cimport Cache_givaro +from sage.rings.finite_rings.element_givaro cimport Cache_givaro cdef class SectionFiniteFieldHomomorphism_givaro(SectionFiniteFieldHomomorphism_generic): diff --git a/src/sage/rings/finite_rings/hom_finite_field_givaro.pyx b/src/sage/rings/finite_rings/hom_finite_field_givaro.pyx index 21036266df1..bc685731610 100644 --- a/src/sage/rings/finite_rings/hom_finite_field_givaro.pyx +++ b/src/sage/rings/finite_rings/hom_finite_field_givaro.pyx @@ -33,21 +33,21 @@ AUTHOR: from sage.rings.finite_rings.finite_field_constructor import FiniteField -from .hom_finite_field cimport SectionFiniteFieldHomomorphism_generic -from .hom_finite_field cimport FiniteFieldHomomorphism_generic -from .hom_finite_field cimport FrobeniusEndomorphism_finite_field +from sage.rings.finite_rings.hom_finite_field cimport SectionFiniteFieldHomomorphism_generic +from sage.rings.finite_rings.hom_finite_field cimport FiniteFieldHomomorphism_generic +from sage.rings.finite_rings.hom_finite_field cimport FrobeniusEndomorphism_finite_field -from .hom_prime_finite_field cimport FiniteFieldHomomorphism_prime +from sage.rings.finite_rings.hom_prime_finite_field cimport FiniteFieldHomomorphism_prime from sage.categories.homset import Hom from sage.structure.element cimport Element from sage.rings.finite_rings.finite_field_givaro import FiniteField_givaro -from .element_givaro cimport FiniteField_givaroElement +from sage.rings.finite_rings.element_givaro cimport FiniteField_givaroElement #from element_givaro cimport make_FiniteField_givaroElement from sage.structure.parent cimport Parent -from .element_givaro cimport Cache_givaro +from sage.rings.finite_rings.element_givaro cimport Cache_givaro cdef class SectionFiniteFieldHomomorphism_givaro(SectionFiniteFieldHomomorphism_generic): diff --git a/src/sage/rings/finite_rings/hom_prime_finite_field.pxd b/src/sage/rings/finite_rings/hom_prime_finite_field.pxd index c0da361fb42..b146b0c9169 100644 --- a/src/sage/rings/finite_rings/hom_prime_finite_field.pxd +++ b/src/sage/rings/finite_rings/hom_prime_finite_field.pxd @@ -1,4 +1,4 @@ -from .hom_finite_field cimport (SectionFiniteFieldHomomorphism_generic, +from sage.rings.finite_rings.hom_finite_field cimport (SectionFiniteFieldHomomorphism_generic, FiniteFieldHomomorphism_generic, FrobeniusEndomorphism_finite_field) diff --git a/src/sage/rings/finite_rings/hom_prime_finite_field.pyx b/src/sage/rings/finite_rings/hom_prime_finite_field.pyx index 6bc38546612..2ff550aa1b1 100644 --- a/src/sage/rings/finite_rings/hom_prime_finite_field.pyx +++ b/src/sage/rings/finite_rings/hom_prime_finite_field.pyx @@ -27,9 +27,9 @@ AUTHOR: from sage.categories.homset import Hom from sage.structure.element cimport Element -from .hom_finite_field cimport SectionFiniteFieldHomomorphism_generic -from .hom_finite_field cimport FiniteFieldHomomorphism_generic -from .hom_finite_field cimport FrobeniusEndomorphism_finite_field +from sage.rings.finite_rings.hom_finite_field cimport SectionFiniteFieldHomomorphism_generic +from sage.rings.finite_rings.hom_finite_field cimport FiniteFieldHomomorphism_generic +from sage.rings.finite_rings.hom_finite_field cimport FrobeniusEndomorphism_finite_field from sage.rings.finite_rings.finite_field_base import FiniteField diff --git a/src/sage/rings/finite_rings/integer_mod_ring.py b/src/sage/rings/finite_rings/integer_mod_ring.py index a448046f137..0bb4ce21f4b 100644 --- a/src/sage/rings/finite_rings/integer_mod_ring.py +++ b/src/sage/rings/finite_rings/integer_mod_ring.py @@ -67,7 +67,7 @@ from sage.arith.misc import CRT_basis import sage.rings.ring as ring import sage.rings.abc -from . import integer_mod +from sage.rings.finite_rings import integer_mod import sage.rings.integer as integer import sage.rings.integer_ring as integer_ring import sage.rings.quotient_ring as quotient_ring diff --git a/src/sage/rings/fraction_field.py b/src/sage/rings/fraction_field.py index 5d298720a90..bfa690cec0e 100644 --- a/src/sage/rings/fraction_field.py +++ b/src/sage/rings/fraction_field.py @@ -83,19 +83,17 @@ # http://www.gnu.org/licenses/ # **************************************************************************** -from . import ring -from . import fraction_field_element import sage.misc.latex as latex +from sage.categories.basic import QuotientFields, Rings +from sage.categories.map import Section from sage.misc.cachefunc import cached_method - +from sage.rings import fraction_field_element, ring from sage.rings.integer_ring import ZZ -from sage.structure.richcmp import richcmp -from sage.structure.parent import Parent -from sage.structure.element import parent from sage.structure.coerce import py_scalar_to_element from sage.structure.coerce_maps import CallableConvertMap, DefaultConvertMap_unique -from sage.categories.basic import QuotientFields, Rings -from sage.categories.map import Section +from sage.structure.element import parent +from sage.structure.parent import Parent +from sage.structure.richcmp import richcmp def FractionField(R, names=None): @@ -327,10 +325,11 @@ def _coerce_map_from_(self, S): sage: f(L(1/7)) == 1/7 True """ - from sage.rings.rational_field import QQ from sage.rings.number_field.number_field_base import NumberField - from sage.rings.polynomial.laurent_polynomial_ring_base import \ - LaurentPolynomialRing_generic + from sage.rings.polynomial.laurent_polynomial_ring_base import ( + LaurentPolynomialRing_generic, + ) + from sage.rings.rational_field import QQ if S is self._R: parent = self._R.Hom(self) @@ -1079,7 +1078,9 @@ def _coerce_map_from_(self, R): 1/t """ - from sage.rings.function_field.function_field_rational import RationalFunctionField + from sage.rings.function_field.function_field_rational import ( + RationalFunctionField, + ) if isinstance(R, RationalFunctionField) and self.variable_name() == R.variable_name() and self.base_ring() is R.constant_base_field(): from sage.categories.homset import Hom parent = Hom(R, self) @@ -1160,8 +1161,8 @@ def section(self): To: Univariate Polynomial Ring in x over Rational Field """ - from sage.categories.sets_with_partial_maps import SetsWithPartialMaps from sage.categories.homset import Hom + from sage.categories.sets_with_partial_maps import SetsWithPartialMaps parent = Hom(self.codomain(), self.domain(), SetsWithPartialMaps()) return parent.__make_element_class__(FractionFieldEmbeddingSection)(self) diff --git a/src/sage/rings/fraction_field_element.pyx b/src/sage/rings/fraction_field_element.pyx index cb0bbce912f..5b6cfa2e29f 100644 --- a/src/sage/rings/fraction_field_element.pyx +++ b/src/sage/rings/fraction_field_element.pyx @@ -22,7 +22,7 @@ AUTHORS: from sage.structure.element cimport FieldElement, parent from sage.structure.richcmp cimport richcmp -from .rational_field import QQ +from sage.rings.rational_field import QQ import sage.misc.latex as latex diff --git a/src/sage/rings/homset.py b/src/sage/rings/homset.py index 0e500de2608..b2f24a3800a 100644 --- a/src/sage/rings/homset.py +++ b/src/sage/rings/homset.py @@ -12,10 +12,11 @@ from sage.categories.homset import HomsetWithBase from sage.categories.rings import Rings + _Rings = Rings() -from . import morphism -from . import quotient_ring +from sage.rings import morphism, quotient_ring + def is_RingHomset(H): """ diff --git a/src/sage/rings/ideal_monoid.py b/src/sage/rings/ideal_monoid.py index 0988ffc72e5..019348a6afe 100644 --- a/src/sage/rings/ideal_monoid.py +++ b/src/sage/rings/ideal_monoid.py @@ -8,10 +8,10 @@ """ -from sage.structure.parent import Parent import sage.rings.integer_ring -from . import ideal from sage.categories.monoids import Monoids +from sage.rings import ideal +from sage.structure.parent import Parent def IdealMonoid(R): diff --git a/src/sage/rings/imaginary_unit.py b/src/sage/rings/imaginary_unit.py index 09349e66e8b..bb29cd32630 100644 --- a/src/sage/rings/imaginary_unit.py +++ b/src/sage/rings/imaginary_unit.py @@ -1,5 +1,5 @@ # coding: utf-8 -from .number_field.number_field import GaussianField +from sage.rings.number_field.number_field import GaussianField I = GaussianField().gen() diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 3ecd0bd986d..143641e4472 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -183,7 +183,7 @@ from sage.structure.element import coerce_binop from sage.structure.richcmp cimport rich_to_bool_sgn -from . import integer_ring +from sage.rings import integer_ring cimport gmpy2 gmpy2.import_gmpy2() diff --git a/src/sage/rings/integer_ring.pxd b/src/sage/rings/integer_ring.pxd index 41afccaa514..d0af1bc068f 100644 --- a/src/sage/rings/integer_ring.pxd +++ b/src/sage/rings/integer_ring.pxd @@ -1,5 +1,5 @@ -from .ring cimport PrincipalIdealDomain -from .integer cimport Integer +from sage.rings.ring cimport PrincipalIdealDomain +from sage.rings.integer cimport Integer from sage.libs.gmp.types cimport mpz_t cdef class IntegerRing_class(PrincipalIdealDomain): diff --git a/src/sage/rings/integer_ring.pyx b/src/sage/rings/integer_ring.pyx index b510c4ba992..1ee45b99a59 100644 --- a/src/sage/rings/integer_ring.pyx +++ b/src/sage/rings/integer_ring.pyx @@ -69,7 +69,7 @@ from sage.misc.randstate cimport randstate, current_randstate, SAGE_RAND_MAX cimport sage.rings.integer as integer -from . import ring +from sage.rings import ring arith = None cdef void late_import() noexcept: diff --git a/src/sage/rings/laurent_series_ring.py b/src/sage/rings/laurent_series_ring.py index 565e5d12f4c..187ac847522 100644 --- a/src/sage/rings/laurent_series_ring.py +++ b/src/sage/rings/laurent_series_ring.py @@ -32,20 +32,17 @@ # **************************************************************************** -from sage.categories.rings import Rings -from sage.rings.infinity import infinity from sage.categories.algebras import Algebras -from sage.categories.integral_domains import IntegralDomains -from sage.categories.fields import Fields from sage.categories.complete_discrete_valuation import CompleteDiscreteValuationFields - -from .laurent_series_ring_element import LaurentSeries -from .ring import CommutativeRing - -from sage.structure.unique_representation import UniqueRepresentation +from sage.categories.fields import Fields +from sage.categories.integral_domains import IntegralDomains +from sage.categories.rings import Rings from sage.misc.cachefunc import cached_method - +from sage.rings.infinity import infinity from sage.rings.integer_ring import ZZ +from sage.rings.laurent_series_ring_element import LaurentSeries +from sage.rings.ring import CommutativeRing +from sage.structure.unique_representation import UniqueRepresentation try: from sage.libs.pari.all import pari_gen @@ -315,8 +312,8 @@ def fraction_field(self): ... ValueError: must be an integral domain """ - from sage.categories.integral_domains import IntegralDomains from sage.categories.fields import Fields + from sage.categories.integral_domains import IntegralDomains if self in Fields(): return self elif self in IntegralDomains(): @@ -489,8 +486,8 @@ def _element_constructor_(self, x, n=0, prec=infinity): x^-3 """ from sage.rings.fraction_field_element import is_FractionFieldElement - from sage.rings.polynomial.polynomial_element import Polynomial from sage.rings.polynomial.multi_polynomial import MPolynomial + from sage.rings.polynomial.polynomial_element import Polynomial from sage.structure.element import parent P = parent(x) @@ -643,9 +640,11 @@ def _coerce_map_from_(self, P): True """ A = self.base_ring() + from sage.rings.polynomial.laurent_polynomial_ring_base import ( + LaurentPolynomialRing_generic, + ) from sage.rings.polynomial.polynomial_ring import is_PolynomialRing from sage.rings.power_series_ring import is_PowerSeriesRing - from sage.rings.polynomial.laurent_polynomial_ring_base import LaurentPolynomialRing_generic if ((is_LaurentSeriesRing(P) or isinstance(P, LaurentPolynomialRing_generic) or diff --git a/src/sage/rings/laurent_series_ring_element.pyx b/src/sage/rings/laurent_series_ring_element.pyx index b15e6cbdcf0..cac7acd812c 100644 --- a/src/sage/rings/laurent_series_ring_element.pyx +++ b/src/sage/rings/laurent_series_ring_element.pyx @@ -66,12 +66,12 @@ AUTHORS: # https://www.gnu.org/licenses/ # **************************************************************************** -from .infinity import infinity +from sage.rings.infinity import infinity from sage.rings.rational_field import QQ import sage.misc.latex from sage.rings.polynomial.laurent_polynomial import LaurentPolynomial_univariate -from .power_series_ring_element cimport PowerSeries +from sage.rings.power_series_ring_element cimport PowerSeries from sage.structure.element cimport Element, AlgebraElement from sage.structure.richcmp cimport richcmp_not_equal, rich_to_bool from sage.misc.derivative import multi_derivative diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx index 9901eff95a3..f8e32bd8c62 100644 --- a/src/sage/rings/morphism.pyx +++ b/src/sage/rings/morphism.pyx @@ -406,7 +406,7 @@ compare equal:: # https://www.gnu.org/licenses/ # **************************************************************************** -from . import ideal +from sage.rings import ideal import sage.structure.all from sage.structure.richcmp cimport (richcmp, rich_to_bool) from sage.misc.cachefunc import cached_method diff --git a/src/sage/rings/number_field/number_field_element_quadratic.pxd b/src/sage/rings/number_field/number_field_element_quadratic.pxd index 76661971848..b9fbb294a54 100644 --- a/src/sage/rings/number_field/number_field_element_quadratic.pxd +++ b/src/sage/rings/number_field/number_field_element_quadratic.pxd @@ -2,7 +2,7 @@ from sage.libs.gmp.types cimport mpz_t from sage.libs.arb.types cimport arb_t from sage.rings.integer cimport Integer from sage.rings.rational cimport Rational -from .number_field_element cimport NumberFieldElement, NumberFieldElement_absolute +from sage.rings.number_field.number_field_element cimport NumberFieldElement, NumberFieldElement_absolute cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute): diff --git a/src/sage/rings/polynomial/multi_polynomial.pxd b/src/sage/rings/polynomial/multi_polynomial.pxd index 73bde26ab51..3f4fe16888c 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pxd +++ b/src/sage/rings/polynomial/multi_polynomial.pxd @@ -1,4 +1,4 @@ -from .commutative_polynomial cimport CommutativePolynomial +from sage.rings.polynomial.commutative_polynomial cimport CommutativePolynomial cdef class MPolynomial(CommutativePolynomial): diff --git a/src/sage/rings/polynomial/polynomial_element.pxd b/src/sage/rings/polynomial/polynomial_element.pxd index b337919a807..9b8bf41fa06 100644 --- a/src/sage/rings/polynomial/polynomial_element.pxd +++ b/src/sage/rings/polynomial/polynomial_element.pxd @@ -2,8 +2,8 @@ from sage.structure.element import Element from sage.structure.element cimport Element, CommutativeAlgebraElement, ModuleElement from sage.structure.parent cimport Parent from sage.rings.integer cimport Integer -from .commutative_polynomial cimport CommutativePolynomial -from .polynomial_compiled cimport CompiledPolynomialFunction +from sage.rings.polynomial.commutative_polynomial cimport CommutativePolynomial +from sage.rings.polynomial.polynomial_compiled cimport CompiledPolynomialFunction cdef class Polynomial(CommutativePolynomial): diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 8e9c4822a7b..ede464edddf 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -118,7 +118,7 @@ from sage.misc.derivative import multi_derivative from sage.arith.misc import sort_complex_numbers_for_display, power_mod, is_prime from sage.arith.functions import lcm -from . import polynomial_fateman +from sage.rings.polynomial import polynomial_fateman from sage.rings.ideal import is_Ideal from sage.rings.polynomial.polynomial_ring import is_PolynomialRing @@ -182,7 +182,7 @@ cpdef is_Polynomial(f) noexcept: return isinstance(f, Polynomial) -from .polynomial_compiled cimport CompiledPolynomialFunction +from sage.rings.polynomial.polynomial_compiled cimport CompiledPolynomialFunction from sage.rings.polynomial.polydict cimport ETuple diff --git a/src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx b/src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx index 15c65081cd9..8bd5bd00a67 100644 --- a/src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx +++ b/src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx @@ -30,7 +30,7 @@ from cpython.long cimport PyLong_AsLong from cpython.float cimport PyFloat_AS_DOUBLE from sage.structure.parent cimport Parent -from .polynomial_element cimport Polynomial, _dict_to_list +from sage.rings.polynomial.polynomial_element cimport Polynomial, _dict_to_list from sage.rings.real_mpfr cimport RealField_class, RealNumber from sage.rings.integer cimport Integer, smallInteger from sage.rings.rational cimport Rational diff --git a/src/sage/rings/power_series_mpoly.pxd b/src/sage/rings/power_series_mpoly.pxd index d358ada1356..d8816e694b7 100644 --- a/src/sage/rings/power_series_mpoly.pxd +++ b/src/sage/rings/power_series_mpoly.pxd @@ -1,5 +1,5 @@ from sage.structure.element cimport ModuleElement -from .power_series_ring_element cimport PowerSeries +from sage.rings.power_series_ring_element cimport PowerSeries cdef class PowerSeries_mpoly(PowerSeries): cdef ModuleElement __f diff --git a/src/sage/rings/power_series_mpoly.pyx b/src/sage/rings/power_series_mpoly.pyx index fa62a7ef6d6..d11eec97269 100644 --- a/src/sage/rings/power_series_mpoly.pyx +++ b/src/sage/rings/power_series_mpoly.pyx @@ -1,10 +1,10 @@ # NOT ready to be used -- possibly should be deleted. -from .power_series_ring_element cimport PowerSeries +from sage.rings.power_series_ring_element cimport PowerSeries from sage.structure.element cimport Element -from .infinity import infinity -from .polynomial.multi_polynomial_ring_base import is_MPolynomialRing -from . import power_series_poly +from sage.rings.infinity import infinity +from sage.rings.polynomial.multi_polynomial_ring_base import is_MPolynomialRing +from sage.rings import power_series_poly cdef class PowerSeries_mpoly(PowerSeries): diff --git a/src/sage/rings/power_series_pari.pxd b/src/sage/rings/power_series_pari.pxd index fadf7f0fd08..35b37929c33 100644 --- a/src/sage/rings/power_series_pari.pxd +++ b/src/sage/rings/power_series_pari.pxd @@ -1,5 +1,5 @@ from cypari2.gen cimport Gen as pari_gen -from .power_series_ring_element cimport PowerSeries +from sage.rings.power_series_ring_element cimport PowerSeries cdef class PowerSeries_pari(PowerSeries): cdef pari_gen g diff --git a/src/sage/rings/power_series_poly.pxd b/src/sage/rings/power_series_poly.pxd index 80c441798a1..e37e1fb26cf 100644 --- a/src/sage/rings/power_series_poly.pxd +++ b/src/sage/rings/power_series_poly.pxd @@ -1,4 +1,4 @@ -from .power_series_ring_element cimport PowerSeries +from sage.rings.power_series_ring_element cimport PowerSeries from sage.rings.polynomial.polynomial_element cimport Polynomial from sage.categories.action cimport Action diff --git a/src/sage/rings/power_series_poly.pyx b/src/sage/rings/power_series_poly.pyx index 519e13c1226..c651fe03d02 100644 --- a/src/sage/rings/power_series_poly.pyx +++ b/src/sage/rings/power_series_poly.pyx @@ -4,9 +4,9 @@ Power Series Methods The class ``PowerSeries_poly`` provides additional methods for univariate power series. """ -from .power_series_ring_element cimport PowerSeries +from sage.rings.power_series_ring_element cimport PowerSeries from sage.structure.element cimport Element -from .infinity import infinity +from sage.rings.infinity import infinity from sage.libs.pari.all import pari_gen, PariError diff --git a/src/sage/rings/power_series_ring.py b/src/sage/rings/power_series_ring.py index b43306adb36..0349bfbe373 100644 --- a/src/sage/rings/power_series_ring.py +++ b/src/sage/rings/power_series_ring.py @@ -134,34 +134,36 @@ """ -from . import power_series_poly -from . import power_series_mpoly -from .power_series_pari import PowerSeries_pari -from . import power_series_ring_element - -from sage.rings.polynomial.polynomial_ring import is_PolynomialRing -from sage.rings.polynomial.multi_polynomial_ring_base import is_MPolynomialRing -from .polynomial.polynomial_ring_constructor import PolynomialRing -from . import laurent_series_ring -from . import laurent_series_ring_element -from . import integer -from . import ring -from .infinity import infinity +import sage.categories.commutative_rings as commutative_rings import sage.misc.latex as latex -from sage.structure.nonexact import Nonexact - from sage.interfaces.abc import MagmaElement -from sage.rings.fraction_field_element import FractionFieldElement from sage.misc.sage_eval import sage_eval - -from sage.structure.unique_representation import UniqueRepresentation +from sage.rings import ( + integer, + laurent_series_ring, + laurent_series_ring_element, + power_series_mpoly, + power_series_poly, + power_series_ring_element, + ring, +) +from sage.rings.fraction_field_element import FractionFieldElement +from sage.rings.infinity import infinity +from sage.rings.polynomial.multi_polynomial_ring_base import is_MPolynomialRing +from sage.rings.polynomial.polynomial_ring import is_PolynomialRing +from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing +from sage.rings.power_series_pari import PowerSeries_pari from sage.structure.category_object import normalize_names -from sage.structure.element import parent, Expression -import sage.categories.commutative_rings as commutative_rings +from sage.structure.element import Expression, parent +from sage.structure.nonexact import Nonexact +from sage.structure.unique_representation import UniqueRepresentation + _CommutativeRings = commutative_rings.CommutativeRings() import sage.categories.integral_domains as integral_domains + _IntegralDomains = integral_domains.IntegralDomains() import sage.categories.fields as fields + _Fields = fields.Fields() from sage.categories.complete_discrete_valuation import CompleteDiscreteValuationRings @@ -535,7 +537,9 @@ def __init__(self, base_ring, name=None, default_prec=None, sparse=False, ValueError: default_prec (= -5) must be non-negative """ - from sage.rings.finite_rings.finite_field_pari_ffelt import FiniteField_pari_ffelt + from sage.rings.finite_rings.finite_field_pari_ffelt import ( + FiniteField_pari_ffelt, + ) if implementation is None: if isinstance(base_ring, FiniteField_pari_ffelt): diff --git a/src/sage/rings/power_series_ring_element.pyx b/src/sage/rings/power_series_ring_element.pyx index b2ce51e09b3..8f570db774a 100644 --- a/src/sage/rings/power_series_ring_element.pyx +++ b/src/sage/rings/power_series_ring_element.pyx @@ -96,7 +96,7 @@ With power series the behavior is the same. # **************************************************************************** from cpython.object cimport Py_EQ, Py_NE -from .infinity import infinity, is_Infinite +from sage.rings.infinity import infinity, is_Infinite from sage.rings.rational_field import QQ @@ -104,7 +104,7 @@ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing import sage.misc.misc import sage.arith.all as arith import sage.misc.latex -from .integer import Integer +from sage.rings.integer import Integer from sage.rings.finite_rings.integer_mod_ring import IntegerModRing from sage.categories.fields import Fields diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py index 3be8051935c..fae8270e5f6 100644 --- a/src/sage/rings/qqbar.py +++ b/src/sage/rings/qqbar.py @@ -557,36 +557,52 @@ import itertools import operator -import sage.rings.ring import sage.rings.abc import sage.rings.number_field.number_field_base -from sage.misc.fast_methods import Singleton +import sage.rings.ring +from sage.arith.misc import factor +from sage.categories.action import Action from sage.misc.cachefunc import cached_method +from sage.misc.fast_methods import Singleton from sage.misc.lazy_string import lazy_string from sage.misc.misc import increase_recursion_limit -from sage.structure.coerce import parent_is_numerical, parent_is_real_numerical -from sage.structure.sage_object import SageObject -from sage.structure.richcmp import (richcmp, richcmp_method, - rich_to_bool, richcmp_not_equal, - op_EQ, op_NE, op_GT) -from sage.rings.real_arb import RealBallField -from sage.rings.real_mpfr import RR -from sage.rings.real_mpfi import RealIntervalField, RIF, is_RealIntervalFieldElement, RealIntervalField_class +from sage.rings import infinity from sage.rings.cc import CC from sage.rings.cif import CIF -from sage.rings.complex_interval_field import ComplexIntervalField from sage.rings.complex_interval import is_ComplexIntervalFieldElement -from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing -from sage.rings.polynomial.polynomial_element import Polynomial +from sage.rings.complex_interval_field import ComplexIntervalField from sage.rings.integer_ring import ZZ +from sage.rings.number_field.number_field import ( + CyclotomicField, + GaussianField, + NumberField, +) +from sage.rings.number_field.number_field_element_quadratic import ( + NumberFieldElement_gaussian, +) +from sage.rings.polynomial.polynomial_element import Polynomial +from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.rational_field import QQ -from sage.rings.number_field.number_field import NumberField, GaussianField, CyclotomicField -from sage.rings.number_field.number_field_element_quadratic import NumberFieldElement_gaussian -from sage.arith.misc import factor -from . import infinity -from sage.categories.action import Action - +from sage.rings.real_arb import RealBallField +from sage.rings.real_mpfi import ( + RIF, + RealIntervalField, + RealIntervalField_class, + is_RealIntervalFieldElement, +) +from sage.rings.real_mpfr import RR +from sage.structure.coerce import parent_is_numerical, parent_is_real_numerical from sage.structure.global_options import GlobalOptions +from sage.structure.richcmp import ( + op_EQ, + op_GT, + op_NE, + rich_to_bool, + richcmp, + richcmp_method, + richcmp_not_equal, +) +from sage.structure.sage_object import SageObject class AlgebraicField_common(sage.rings.abc.AlgebraicField_common): @@ -888,8 +904,8 @@ def _factor_multivariate_polynomial(self, f, proof=True): 1 """ - from sage.structure.factorization import Factorization from sage.interfaces.singular import singular + from sage.structure.factorization import Factorization if f.degree() == 0: return Factorization([], f.lc()) @@ -1973,8 +1989,8 @@ def random_element(self, poly_degree=2, *args, **kwds): sage: v # random (0.4694381338921299?, -0.500000000000000? + 0.866025403784439?*I) """ - from sage.rings.integer_ring import ZZ import sage.misc.prandom + from sage.rings.integer_ring import ZZ try: poly_degree = ZZ(poly_degree) except TypeError: @@ -3437,7 +3453,7 @@ def __call__(self, elt): return elt.field_element_value() gen = elt.generator() sp = gen.super_poly(self) - assert (not (sp is None)) + assert (sp is not None) return self._field(elt.field_element_value().polynomial()(sp)) @@ -5313,7 +5329,7 @@ def multiplicative_order(self): sage: QQbar(3/5 + 4/5*I).multiplicative_order() +Infinity """ - if not (1 in CIF(self).norm()): + if 1 not in CIF(self).norm(): return infinity.infinity if self.norm() != 1: return infinity.infinity @@ -5797,7 +5813,7 @@ def multiplicative_order(self): sage: AA(5).sqrt().multiplicative_order() +Infinity """ - if not (1 in RIF(self).abs()): + if 1 not in RIF(self).abs(): return infinity.infinity if self == 1: return 1 @@ -7384,7 +7400,7 @@ def _complex_refine_interval(self, interval, prec): # Give up and fall back on root isolation. return self._complex_isolate_interval(interval, prec) - if not (zero in slope): + if zero not in slope: new_range = center - val / slope interval = interval.intersection(new_range) @@ -8585,7 +8601,6 @@ def exactify(self): 1000 sage: sys.setrecursionlimit(old_recursion_limit) """ - import sys with increase_recursion_limit(10): left = self._left right = self._right @@ -8814,5 +8829,6 @@ def get_AA_golden_ratio(): # Support Python's numbers abstract base class import numbers + numbers.Real.register(AlgebraicReal) numbers.Complex.register(AlgebraicNumber) diff --git a/src/sage/rings/quotient_ring.py b/src/sage/rings/quotient_ring.py index 7dc4e0803c8..a6a0a8ce7f8 100644 --- a/src/sage/rings/quotient_ring.py +++ b/src/sage/rings/quotient_ring.py @@ -112,16 +112,15 @@ # (at your option) any later version. # http://www.gnu.org/licenses/ # **************************************************************************** +import sage.interfaces.abc import sage.misc.latex as latex -from . import ring, ideal, quotient_ring_element -from sage.structure.category_object import normalize_names -from sage.structure.richcmp import richcmp_method, richcmp import sage.structure.parent_gens -from sage.misc.cachefunc import cached_method -from sage.categories.rings import Rings from sage.categories.commutative_rings import CommutativeRings - -import sage.interfaces.abc +from sage.categories.rings import Rings +from sage.misc.cachefunc import cached_method +from sage.rings import ideal, quotient_ring_element, ring +from sage.structure.category_object import normalize_names +from sage.structure.richcmp import richcmp, richcmp_method _Rings = Rings() _CommRings = CommutativeRings() @@ -302,7 +301,9 @@ def QuotientRing(R, I, names=None, **kwds): else: names = normalize_names(R.ngens(), names) if kwds.get('implementation') == 'pbori': - from sage.rings.polynomial.polynomial_ring_constructor import BooleanPolynomialRing_constructor as BooleanPolynomialRing + from sage.rings.polynomial.polynomial_ring_constructor import ( + BooleanPolynomialRing_constructor as BooleanPolynomialRing, + ) kwds.pop('implementation') return BooleanPolynomialRing(R.ngens(), names=names, **kwds) # workaround to silence warning from #34806 @@ -538,6 +539,7 @@ def construction(self): Finite Field of size 5 """ from sage.categories.pushout import QuotientFunctor + # Is there a better generic way to distinguish between things like Z/pZ as a field and Z/pZ as a ring? from sage.rings.ring import Field try: @@ -1006,7 +1008,9 @@ def ideal(self, *gens, **kwds): """ if len(gens) == 1: gens = gens[0] - from sage.rings.polynomial.multi_polynomial_ring_base import MPolynomialRing_base + from sage.rings.polynomial.multi_polynomial_ring_base import ( + MPolynomialRing_base, + ) if not (isinstance(self.__R, MPolynomialRing_base) and self.__R._has_singular): # pass through return super().ideal(gens, **kwds) @@ -1019,7 +1023,9 @@ def ideal(self, *gens, **kwds): global MPolynomialIdeal_quotient if MPolynomialIdeal_quotient is None: - from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal_quotient + from sage.rings.polynomial.multi_polynomial_ideal import ( + MPolynomialIdeal_quotient, + ) return MPolynomialIdeal_quotient(self, gens, **kwds) def _element_constructor_(self, x, coerce=True): @@ -1276,7 +1282,7 @@ def _singular_(self, singular=None): try: Q = self.__singular - if not (Q.parent() is singular): + if Q.parent() is not singular: raise ValueError Q._check_valid() return Q diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx index 0b398428006..63ad2b36bee 100644 --- a/src/sage/rings/rational.pyx +++ b/src/sage/rings/rational.pyx @@ -72,9 +72,9 @@ from sage.structure.richcmp cimport rich_to_bool_sgn import sage.rings.rational_field cimport sage.rings.integer as integer -from .integer cimport Integer +from sage.rings.integer cimport Integer -from .integer_ring import ZZ +from sage.rings.integer_ring import ZZ from sage.structure.coerce cimport is_numpy_type diff --git a/src/sage/rings/rational_field.py b/src/sage/rings/rational_field.py index 7296d227097..341c0d536d0 100644 --- a/src/sage/rings/rational_field.py +++ b/src/sage/rings/rational_field.py @@ -54,16 +54,17 @@ """ -from .rational import Rational -from .integer import Integer +from sage.rings.integer import Integer +from sage.rings.rational import Rational ZZ = None -from sage.structure.parent_gens import ParentWithGens -from sage.structure.sequence import Sequence import sage.rings.number_field.number_field_base as number_field_base from sage.misc.fast_methods import Singleton from sage.misc.superseded import deprecated_function_alias +from sage.structure.parent_gens import ParentWithGens +from sage.structure.sequence import Sequence + class RationalField(Singleton, number_field_base.NumberField): r""" @@ -317,6 +318,7 @@ def construction(self): (FractionField, Integer Ring) """ from sage.categories.pushout import FractionField + from . import integer_ring return FractionField(), integer_ring.ZZ @@ -446,8 +448,8 @@ def __truediv__(self, I): sage: QQ / ZZ # needs sage.modules Q/Z """ - from sage.rings.ideal import Ideal_generic from sage.groups.additive_abelian.qmodnz import QmodnZ + from sage.rings.ideal import Ideal_generic if I is ZZ: return QmodnZ(1) elif isinstance(I, Ideal_generic) and I.base_ring() is ZZ: @@ -834,15 +836,15 @@ def hilbert_symbol_negative_at_S(self, S, b, check=True): - Simon Brandhorst, Juanita Duque, Anna Haensch, Manami Roy, Sandi Rudzinski (10-24-2017) """ + from sage.arith.misc import hilbert_symbol, is_prime + from sage.matrix.constructor import matrix + from sage.modules.free_module import VectorSpace from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF from sage.rings.padics.factory import Qp - from sage.modules.free_module import VectorSpace - from sage.matrix.constructor import matrix from sage.sets.primes import Primes - from sage.arith.misc import hilbert_symbol, is_prime # input checks - if not type(S) is list: + if type(S) is not list: raise TypeError("first argument must be a list or integer") # -1 is used for the infinite place infty = -1 @@ -1375,8 +1377,9 @@ def selmer_group_iterator(self, S, m, proof=True): """ KSgens, ords = self.selmer_generators(S=S, m=m, proof=proof, orders=True) one = self.one() - from sage.misc.misc_c import prod from itertools import product + + from sage.misc.misc_c import prod for ev in product(*[range(o) for o in ords]): yield prod((p**e for p,e in zip(KSgens, ev)), one) @@ -1490,8 +1493,8 @@ def quadratic_defect(self, a, p, check=True): sage: QQ.quadratic_defect(5, 5) 1 """ - from sage.rings.infinity import Infinity from sage.arith.misc import legendre_symbol + from sage.rings.infinity import Infinity if a not in self: raise TypeError(str(a) + " must be an element of " + str(self)) if p.parent() == ZZ.ideal_monoid(): @@ -1596,8 +1599,8 @@ def _sympy_(self): sage: QQ._sympy_() # needs sympy Rationals """ - from sympy import Rationals from sage.interfaces.sympy import sympy_init + from sympy import Rationals sympy_init() return Rationals diff --git a/src/sage/rings/real_double_element_gsl.pxd b/src/sage/rings/real_double_element_gsl.pxd index 39c36999ec4..1762c5f944b 100644 --- a/src/sage/rings/real_double_element_gsl.pxd +++ b/src/sage/rings/real_double_element_gsl.pxd @@ -1,4 +1,4 @@ -from .real_double cimport RealDoubleElement +from sage.rings.real_double cimport RealDoubleElement cdef class RealDoubleElement_gsl(RealDoubleElement): diff --git a/src/sage/rings/real_mpfi.pxd b/src/sage/rings/real_mpfi.pxd index 32332d81e3e..f9fc7a1969c 100644 --- a/src/sage/rings/real_mpfi.pxd +++ b/src/sage/rings/real_mpfi.pxd @@ -5,8 +5,8 @@ from sage.rings.ring cimport Field cimport sage.rings.abc from sage.structure.element cimport RingElement -from .rational cimport Rational -from .real_mpfr cimport RealField_class +from sage.rings.rational cimport Rational +from sage.rings.real_mpfr cimport RealField_class cdef class RealIntervalFieldElement(RingElement) # forward decl diff --git a/src/sage/rings/real_mpfi.pyx b/src/sage/rings/real_mpfi.pyx index 6e389b53ac2..58e3d8de737 100644 --- a/src/sage/rings/real_mpfi.pyx +++ b/src/sage/rings/real_mpfi.pyx @@ -269,11 +269,11 @@ from sage.structure.element cimport have_same_parent from sage.structure.parent cimport Parent from sage.structure.richcmp cimport richcmp -from .convert.mpfi cimport mpfi_set_sage -from .real_mpfr cimport RealField_class, RealNumber, RealField -from .integer cimport Integer -from .integer_ring import ZZ -from .rational_field import QQ +from sage.rings.convert.mpfi cimport mpfi_set_sage +from sage.rings.real_mpfr cimport RealField_class, RealNumber, RealField +from sage.rings.integer cimport Integer +from sage.rings.integer_ring import ZZ +from sage.rings.rational_field import QQ cimport sage.rings.abc diff --git a/src/sage/rings/real_mpfr.pyx b/src/sage/rings/real_mpfr.pyx index 4a091fd9191..9117dfcd4ce 100644 --- a/src/sage/rings/real_mpfr.pyx +++ b/src/sage/rings/real_mpfr.pyx @@ -148,12 +148,12 @@ from cypari2.stack cimport new_gen from sage.libs.mpmath.utils cimport mpfr_to_mpfval -from .integer cimport Integer -from .rational cimport Rational +from sage.rings.integer cimport Integer +from sage.rings.rational cimport Rational from sage.categories.map cimport Map -from .real_double cimport RealDoubleElement +from sage.rings.real_double cimport RealDoubleElement import sage.rings.rational_field diff --git a/src/sage/rings/sum_of_squares.pyx b/src/sage/rings/sum_of_squares.pyx index e6ec62dc7f1..04be29e0fdc 100644 --- a/src/sage/rings/sum_of_squares.pyx +++ b/src/sage/rings/sum_of_squares.pyx @@ -22,7 +22,7 @@ from libc.math cimport sqrt from cysignals.signals cimport sig_on, sig_off cimport sage.rings.integer as integer -from . import integer +from sage.rings import integer cdef int two_squares_c(uint_fast32_t n, uint_fast32_t res[2]) noexcept: r"""