From 44af9b91712a6628d80aa8d872327e0d48b2d7c3 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 29 Jan 2023 18:50:21 -0800 Subject: [PATCH] sage.schemes: Consolidate imports from the same module --- .../elliptic_curves/ell_finite_field.py | 26 +++++------ .../elliptic_curves/ell_modular_symbols.py | 20 ++++---- .../elliptic_curves/ell_rational_field.py | 3 +- .../elliptic_curves/gal_reps_number_field.py | 13 +++--- src/sage/schemes/elliptic_curves/heegner.py | 45 ++++++++---------- .../schemes/elliptic_curves/hom_velusqrt.py | 20 ++++---- .../schemes/elliptic_curves/mod_sym_num.pyx | 12 ++--- .../schemes/elliptic_curves/padic_lseries.py | 46 +++++++++---------- src/sage/schemes/elliptic_curves/padics.py | 27 ++++++----- .../schemes/elliptic_curves/period_lattice.py | 18 ++++---- 10 files changed, 108 insertions(+), 122 deletions(-) diff --git a/src/sage/schemes/elliptic_curves/ell_finite_field.py b/src/sage/schemes/elliptic_curves/ell_finite_field.py index c607b460603..dc13b954ced 100644 --- a/src/sage/schemes/elliptic_curves/ell_finite_field.py +++ b/src/sage/schemes/elliptic_curves/ell_finite_field.py @@ -23,24 +23,24 @@ # https://www.gnu.org/licenses/ # **************************************************************************** +import sage.groups.generic as generic -from sage.schemes.curves.projective_curve import Hasse_bounds -from .ell_field import EllipticCurve_field -from .constructor import EllipticCurve -from sage.schemes.hyperelliptic_curves.hyperelliptic_finite_field import HyperellipticCurve_finite_field +from sage.arith.functions import lcm +from sage.arith.misc import binomial, GCD as gcd +from sage.groups.additive_abelian.additive_abelian_wrapper import AdditiveAbelianGroupWrapper +from sage.misc.cachefunc import cached_method +from sage.rings.finite_rings.element_base import is_FiniteFieldElement +from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF from sage.rings.integer import Integer from sage.rings.integer_ring import ZZ -from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing -from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF from sage.rings.polynomial.polynomial_ring import polygen -from sage.rings.finite_rings.element_base import is_FiniteFieldElement -import sage.groups.generic as generic +from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing +from sage.schemes.curves.projective_curve import Hasse_bounds +from sage.schemes.hyperelliptic_curves.hyperelliptic_finite_field import HyperellipticCurve_finite_field + from . import ell_point -from sage.arith.misc import GCD as gcd -from sage.arith.functions import lcm -from sage.arith.misc import binomial -from sage.misc.cachefunc import cached_method -from sage.groups.additive_abelian.additive_abelian_wrapper import AdditiveAbelianGroupWrapper +from .constructor import EllipticCurve +from .ell_field import EllipticCurve_field class EllipticCurve_finite_field(EllipticCurve_field, HyperellipticCurve_finite_field): diff --git a/src/sage/schemes/elliptic_curves/ell_modular_symbols.py b/src/sage/schemes/elliptic_curves/ell_modular_symbols.py index af294cae2fe..b31f7dfe46c 100644 --- a/src/sage/schemes/elliptic_curves/ell_modular_symbols.py +++ b/src/sage/schemes/elliptic_curves/ell_modular_symbols.py @@ -87,22 +87,22 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from sage.structure.sage_object import SageObject -from sage.modular.modsym.all import ModularSymbols +from sage.arith.misc import (kronecker as kronecker_symbol, + next_prime, + prime_divisors, + valuation) from sage.databases.cremona import parse_cremona_label - -from sage.arith.misc import next_prime -from sage.arith.misc import kronecker as kronecker_symbol -from sage.arith.misc import prime_divisors -from sage.arith.misc import valuation +from sage.misc.verbose import verbose +from sage.modular.cusps import Cusps +from sage.modular.modsym.all import ModularSymbols from sage.rings.infinity import unsigned_infinity as infinity from sage.rings.integer import Integer -from sage.modular.cusps import Cusps from sage.rings.integer_ring import ZZ from sage.rings.rational_field import QQ -from sage.misc.verbose import verbose +from sage.structure.sage_object import SageObject + +from .constructor import EllipticCurve -from sage.schemes.elliptic_curves.constructor import EllipticCurve oo = Cusps(infinity) zero = Integer(0) diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py index 433eebfa3e6..f7623bafba2 100644 --- a/src/sage/schemes/elliptic_curves/ell_rational_field.py +++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py @@ -76,10 +76,9 @@ import sage.rings.all as rings from sage.rings.power_series_ring import PowerSeriesRing from sage.rings.infinity import Infinity as oo -from sage.rings.integer_ring import ZZ +from sage.rings.integer_ring import ZZ, IntegerRing from sage.rings.rational_field import QQ from sage.rings.integer import Integer -from sage.rings.integer_ring import IntegerRing from sage.rings.real_mpfr import RealField from sage.rings.complex_mpfr import ComplexField from sage.rings.rational_field import RationalField diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py index 5b0dd7161bb..0588b97bb3d 100644 --- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py +++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py @@ -45,18 +45,17 @@ # https://www.gnu.org/licenses/ # **************************************************************************** -from sage.structure.sage_object import SageObject -from sage.rings.number_field.number_field import NumberField +from sage.arith.misc import legendre_symbol, primes +from sage.misc.functional import cyclotomic_polynomial from sage.modules.free_module import VectorSpace from sage.rings.finite_rings.finite_field_constructor import GF -from sage.misc.functional import cyclotomic_polynomial -from sage.arith.misc import legendre_symbol -from sage.arith.misc import primes -from sage.sets.set import Set +from sage.rings.infinity import Infinity from sage.rings.integer import Integer from sage.rings.integer_ring import ZZ +from sage.rings.number_field.number_field import NumberField from sage.rings.rational_field import QQ -from sage.rings.infinity import Infinity +from sage.sets.set import Set +from sage.structure.sage_object import SageObject class GaloisRepresentation(SageObject): diff --git a/src/sage/schemes/elliptic_curves/heegner.py b/src/sage/schemes/elliptic_curves/heegner.py index c23e6bb5a46..f9b752f9533 100644 --- a/src/sage/schemes/elliptic_curves/heegner.py +++ b/src/sage/schemes/elliptic_curves/heegner.py @@ -92,41 +92,34 @@ # https://www.gnu.org/licenses/ # **************************************************************************** - -from sage.misc.misc_c import prod -from sage.misc.verbose import verbose -from sage.misc.cachefunc import cached_method - -from sage.structure.sage_object import SageObject -from sage.structure.richcmp import (richcmp_method, richcmp, - richcmp_not_equal, rich_to_bool) - import sage.rings.abc import sage.rings.number_field.number_field_element import sage.rings.number_field.number_field as number_field import sage.rings.all as rings -from sage.rings.integer_ring import ZZ -from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF -from sage.rings.rational_field import QQ + +from sage.arith.functions import lcm +from sage.arith.misc import (binomial, factorial, prime_divisors, + GCD as gcd, XGCD as xgcd) +from sage.matrix.constructor import Matrix as matrix +from sage.matrix.matrix_space import MatrixSpace +from sage.misc.cachefunc import cached_method +from sage.misc.misc_c import prod +from sage.misc.verbose import verbose +from sage.modular.modsym.p1list import P1List from sage.rings.complex_double import CDF -from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as Integers -from sage.rings.real_mpfr import RealField from sage.rings.complex_mpfr import ComplexField -from sage.rings.number_field.number_field import QuadraticField -from sage.arith.misc import GCD as gcd -from sage.arith.misc import XGCD as xgcd -from sage.arith.functions import lcm -from sage.arith.misc import prime_divisors -from sage.arith.misc import factorial -from sage.arith.misc import binomial from sage.rings.factorint import factor_trial_division +from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF +from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as Integers +from sage.rings.integer_ring import ZZ +from sage.rings.number_field.number_field import QuadraticField +from sage.rings.rational_field import QQ +from sage.rings.real_mpfr import RealField from sage.quadratic_forms.all import (BinaryQF, BinaryQF_reduced_representatives) -from sage.matrix.matrix_space import MatrixSpace -from sage.matrix.constructor import Matrix as matrix - -from sage.modular.modsym.p1list import P1List - +from sage.structure.sage_object import SageObject +from sage.structure.richcmp import (richcmp_method, richcmp, + richcmp_not_equal, rich_to_bool) ############################################################################### # diff --git a/src/sage/schemes/elliptic_curves/hom_velusqrt.py b/src/sage/schemes/elliptic_curves/hom_velusqrt.py index f8c3f522e6e..e24e575edbe 100644 --- a/src/sage/schemes/elliptic_curves/hom_velusqrt.py +++ b/src/sage/schemes/elliptic_curves/hom_velusqrt.py @@ -122,20 +122,16 @@ # https://www.gnu.org/licenses/ # **************************************************************************** -from sage.structure.sequence import Sequence -from sage.structure.all import coercion_model as cm - from sage.misc.cachefunc import cached_method - from sage.misc.misc_c import prod - -from sage.structure.richcmp import op_EQ - from sage.rings.integer import Integer +from sage.structure.all import coercion_model as cm +from sage.structure.richcmp import op_EQ +from sage.structure.sequence import Sequence -from sage.schemes.elliptic_curves.constructor import EllipticCurve -from sage.schemes.elliptic_curves.ell_finite_field import EllipticCurve_finite_field -from sage.schemes.elliptic_curves.hom import EllipticCurveHom, compare_via_evaluation +from .constructor import EllipticCurve +from .ell_finite_field import EllipticCurve_finite_field +from .hom import EllipticCurveHom, compare_via_evaluation # TODO: This is general. It should be elsewhere. @@ -1406,11 +1402,11 @@ def _random_example_for_testing(): True """ from sage.rings.fast_arith import prime_range - from sage.misc.prandom import choice - from sage.misc.prandom import randrange + from sage.misc.prandom import choice, randrange from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF from sage.arith.functions import lcm from sage.rings.finite_rings.integer_mod import Mod + while True: p = choice(prime_range(2, 100)) e = randrange(1,5) diff --git a/src/sage/schemes/elliptic_curves/mod_sym_num.pyx b/src/sage/schemes/elliptic_curves/mod_sym_num.pyx index 1902dea1c78..369cd98a293 100644 --- a/src/sage/schemes/elliptic_curves/mod_sym_num.pyx +++ b/src/sage/schemes/elliptic_curves/mod_sym_num.pyx @@ -164,18 +164,16 @@ AUTHORS: from cysignals.memory cimport sig_malloc, sig_free, sig_realloc from cysignals.signals cimport sig_check +from sage.arith.misc import euler_phi, kronecker as kronecker_symbol from sage.misc.cachefunc import cached_method - +from sage.misc.misc_c import prod +from sage.misc.verbose import verbose from sage.rings.complex_mpfr cimport ComplexNumber from sage.rings.complex_mpfr import ComplexField -from sage.rings.real_mpfr cimport RealNumber, RealField -from sage.rings.rational cimport Rational from sage.rings.integer cimport Integer +from sage.rings.rational cimport Rational +from sage.rings.real_mpfr cimport RealNumber, RealField -from sage.misc.misc_c import prod -from sage.misc.verbose import verbose -from sage.arith.misc import kronecker as kronecker_symbol -from sage.arith.misc import euler_phi cdef extern from "": double log(double) diff --git a/src/sage/schemes/elliptic_curves/padic_lseries.py b/src/sage/schemes/elliptic_curves/padic_lseries.py index e7125d92dfd..875a4113464 100644 --- a/src/sage/schemes/elliptic_curves/padic_lseries.py +++ b/src/sage/schemes/elliptic_curves/padic_lseries.py @@ -61,35 +61,33 @@ # https://www.gnu.org/licenses/ ###################################################################### -from sage.rings.integer_ring import ZZ -from sage.rings.rational_field import QQ -from sage.rings.padics.factory import Qp -from sage.rings.infinity import infinity -from sage.rings.laurent_series_ring import LaurentSeriesRing -from sage.rings.power_series_ring import PowerSeriesRing -from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing -from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as Integers - -from sage.rings.integer import Integer -from sage.arith.misc import valuation -from sage.arith.misc import binomial -from sage.arith.misc import kronecker as kronecker_symbol -from sage.arith.misc import GCD as gcd -from sage.arith.misc import prime_divisors -from sage.arith.functions import lcm as LCM - -from sage.structure.sage_object import SageObject -from sage.structure.richcmp import richcmp_method, richcmp - -from sage.misc.functional import denominator -from sage.misc.verbose import verbose, get_verbose - -from sage.modules.free_module_element import vector import sage.matrix.all as matrix import sage.schemes.hyperelliptic_curves.monsky_washnitzer + +from sage.arith.functions import lcm as LCM +from sage.arith.misc import (binomial, + GCD as gcd, + prime_divisors, + kronecker as kronecker_symbol, + valuation) from sage.functions.log import log from sage.functions.other import floor from sage.misc.cachefunc import cached_method +from sage.misc.functional import denominator +from sage.misc.verbose import get_verbose, verbose +from sage.modules.free_module_element import vector +from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as Integers +from sage.rings.infinity import infinity +from sage.rings.integer import Integer +from sage.rings.integer_ring import ZZ +from sage.rings.laurent_series_ring import LaurentSeriesRing +from sage.rings.padics.factory import Qp +from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing +from sage.rings.power_series_ring import PowerSeriesRing +from sage.rings.rational_field import QQ +from sage.structure.richcmp import richcmp_method, richcmp +from sage.structure.sage_object import SageObject + @richcmp_method class pAdicLseries(SageObject): diff --git a/src/sage/schemes/elliptic_curves/padics.py b/src/sage/schemes/elliptic_curves/padics.py index 6ba2532fbad..a90a5090fce 100644 --- a/src/sage/schemes/elliptic_curves/padics.py +++ b/src/sage/schemes/elliptic_curves/padics.py @@ -21,25 +21,28 @@ # https://www.gnu.org/licenses/ ###################################################################### +import math -import sage.rings.all as rings -from . import padic_lseries as plseries import sage.arith.all as arith -from sage.rings.padics.factory import Qp -from sage.rings.padics.factory import Zp +import sage.matrix.all as matrix +import sage.misc.misc as misc +import sage.rings.all as rings +import sage.schemes.hyperelliptic_curves.hypellfrob +import sage.schemes.hyperelliptic_curves.monsky_washnitzer + +from sage.misc.cachefunc import cached_method +from sage.rings.big_oh import O from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as Integers from sage.rings.integer import Integer -from sage.rings.big_oh import O -from sage.rings.power_series_ring import PowerSeriesRing from sage.rings.laurent_series_ring import LaurentSeriesRing +from sage.rings.padics.factory import Qp, Zp +from sage.rings.power_series_ring import PowerSeriesRing from sage.rings.rational_field import RationalField -import math -import sage.misc.misc as misc -import sage.matrix.all as matrix + +from . import padic_lseries as plseries + sqrt = math.sqrt -import sage.schemes.hyperelliptic_curves.monsky_washnitzer -import sage.schemes.hyperelliptic_curves.hypellfrob -from sage.misc.cachefunc import cached_method + def __check_padic_hypotheses(self, p): r""" diff --git a/src/sage/schemes/elliptic_curves/period_lattice.py b/src/sage/schemes/elliptic_curves/period_lattice.py index cc75366a917..7224988fc27 100644 --- a/src/sage/schemes/elliptic_curves/period_lattice.py +++ b/src/sage/schemes/elliptic_curves/period_lattice.py @@ -96,22 +96,22 @@ """ +import sage.rings.abc + +from sage.libs.pari.all import pari +from sage.misc.cachefunc import cached_method from sage.modules.free_module import FreeModule_generic_pid +from sage.rings.complex_mpfr import ComplexField +from sage.rings.complex_mpfr import ComplexNumber +from sage.rings.infinity import Infinity from sage.rings.integer_ring import ZZ +from sage.rings.number_field.number_field import refine_embedding +from sage.rings.qqbar import AA, QQbar from sage.rings.rational_field import QQ from sage.rings.real_mpfr import RealField -from sage.rings.complex_mpfr import ComplexField -from sage.rings.qqbar import QQbar -from sage.rings.qqbar import AA -import sage.rings.abc -from sage.rings.complex_mpfr import ComplexNumber from sage.rings.real_mpfr import RealNumber as RealNumber -from sage.rings.number_field.number_field import refine_embedding -from sage.rings.infinity import Infinity from sage.schemes.elliptic_curves.constructor import EllipticCurve -from sage.misc.cachefunc import cached_method from sage.structure.richcmp import richcmp_method, richcmp, richcmp_not_equal -from sage.libs.pari.all import pari class PeriodLattice(FreeModule_generic_pid):