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

Commit

Permalink
sage.{crypto,databases,dynamics,lfunctions,quadratic_forms}: Consolid…
Browse files Browse the repository at this point in the history
…ate imports from the same module
  • Loading branch information
Matthias Koeppe committed Jan 30, 2023
1 parent 35300bd commit 28760be
Show file tree
Hide file tree
Showing 20 changed files with 130 additions and 147 deletions.
3 changes: 1 addition & 2 deletions src/sage/crypto/classical.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
from sage.rings.integer import Integer
from sage.rings.integer_ring import ZZ
from sage.rings.finite_rings.integer_mod_ring import IntegerModRing
from sage.arith.misc import XGCD as xgcd
from sage.arith.misc import inverse_mod
from sage.arith.misc import inverse_mod, XGCD as xgcd
from random import randint
from sage.matrix.matrix_space import MatrixSpace

Expand Down
13 changes: 6 additions & 7 deletions src/sage/crypto/lwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,25 @@
- [CGW2013]_
"""

from sage.arith.misc import euler_phi, next_prime
from sage.functions.log import log
from sage.functions.other import floor, ceil
from sage.misc.functional import sqrt
from sage.misc.functional import cyclotomic_polynomial, round
from sage.misc.randstate import set_random_seed
from sage.misc.functional import sqrt
from sage.misc.prandom import randint
from sage.misc.randstate import set_random_seed
from sage.modules.free_module import FreeModule
from sage.modules.free_module_element import random_vector, vector
from sage.numerical.optimize import find_root
from sage.rings.integer_ring import ZZ
from sage.rings.finite_rings.integer_mod_ring import IntegerModRing
from sage.rings.integer_ring import ZZ
from sage.rings.real_mpfr import RR
from sage.arith.misc import next_prime
from sage.arith.misc import euler_phi
from sage.stats.distributions.discrete_gaussian_integer import DiscreteGaussianDistributionIntegerSampler
from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler
from sage.structure.element import parent
from sage.structure.sage_object import SageObject
from sage.symbolic.constants import pi
from sage.symbolic.ring import SR
from sage.stats.distributions.discrete_gaussian_integer import DiscreteGaussianDistributionIntegerSampler
from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler


class UniformSampler(SageObject):
Expand Down
12 changes: 5 additions & 7 deletions src/sage/crypto/public_key/blum_goldwasser.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@

from operator import xor

from sage.crypto.cryptosystem import PublicKeyCryptosystem
from sage.crypto.util import is_blum_prime
from sage.crypto.util import least_significant_bits
from sage.crypto.util import random_blum_prime
from sage.arith.misc import GCD as gcd, power_mod, XGCD as xgcd
from sage.functions.log import log
from sage.functions.other import Function_floor
from sage.monoids.string_monoid import BinaryStrings
from sage.arith.misc import GCD as gcd
from sage.arith.misc import power_mod
from sage.arith.misc import XGCD as xgcd
from sage.rings.finite_rings.integer_mod import Mod as mod
from sage.rings.finite_rings.integer_mod_ring import IntegerModFactory

from .cryptosystem import PublicKeyCryptosystem
from .util import is_blum_prime, least_significant_bits, random_blum_prime


floor = Function_floor()
IntegerModRing = IntegerModFactory("IntegerModRing")

Expand Down
11 changes: 5 additions & 6 deletions src/sage/crypto/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
# http://www.gnu.org/licenses/
#*****************************************************************************

from .cryptosystem import SymmetricKeyCryptosystem
from .stream_cipher import LFSRCipher, ShrinkingGeneratorCipher

from sage.crypto.util import random_blum_prime
from sage.arith.misc import GCD as gcd, power_mod
from sage.monoids.string_monoid import BinaryStrings
from sage.arith.misc import GCD as gcd
from sage.arith.misc import power_mod
from sage.rings.finite_rings.finite_field_constructor import FiniteField
from sage.rings.finite_rings.integer_mod_ring import IntegerModFactory
from sage.rings.polynomial.polynomial_element import is_Polynomial

from .cryptosystem import SymmetricKeyCryptosystem
from .stream_cipher import LFSRCipher, ShrinkingGeneratorCipher
from .util import random_blum_prime


IntegerModRing = IntegerModFactory("IntegerModRing")

Expand Down
11 changes: 5 additions & 6 deletions src/sage/crypto/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@
# http://www.gnu.org/licenses/
#*****************************************************************************

from sage.monoids.string_monoid import BinaryStrings
from sage.arith.misc import is_prime
from sage.arith.functions import lcm
from sage.arith.misc import primes
from sage.arith.misc import random_prime
from sage.rings.integer import Integer
from sage.arith.misc import is_prime, primes, random_prime
from sage.misc.lazy_import import lazy_import
from sage.monoids.string_monoid import BinaryStrings
from sage.rings.finite_rings.integer_mod import Mod as mod
from sage.rings.integer import Integer

from sage.misc.lazy_import import lazy_import
lazy_import('sage.arith.misc', ('carmichael_lambda'), deprecation=34719)


def ascii_integer(B):
r"""
Return the ASCII integer corresponding to the binary string ``B``.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,23 @@
from copy import copy, deepcopy
from itertools import permutations, combinations, product

from sage.arith.functions import lcm
from sage.arith.misc import CRT, divisors, GCD as gcd, is_square
from sage.combinat.permutation import Arrangements
from sage.combinat.subset import Subsets
from sage.misc.functional import sqrt
from sage.matrix.constructor import matrix
from sage.structure.element import is_Matrix
from sage.misc.functional import sqrt
from sage.misc.misc_c import prod
from sage.parallel.use_fork import p_iter_fork
from sage.rings.finite_rings.finite_field_constructor import GF
from sage.rings.finite_rings.integer_mod_ring import Integers
from sage.rings.integer_ring import ZZ
from sage.rings.number_field.number_field import NumberField
from sage.arith.misc import GCD as gcd
from sage.arith.functions import lcm
from sage.arith.misc import CRT
from sage.arith.misc import is_square
from sage.arith.misc import divisors
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.rational_field import QQ
from sage.sets.primes import Primes
from sage.sets.set import Set
from sage.combinat.permutation import Arrangements
from sage.parallel.use_fork import p_iter_fork
from sage.structure.element import is_Matrix


def automorphism_group_QQ_fixedpoints(rational_function, return_functions=False, iso_type=False):
Expand Down
41 changes: 19 additions & 22 deletions src/sage/dynamics/arithmetic_dynamics/projective_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,29 @@ class initialization directly.
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.arith.misc import is_prime
from copy import copy
from itertools import count, product

import sage.rings.abc

from sage.arith.functions import lcm
from sage.arith.misc import binomial, GCD as gcd, is_prime, moebius, next_prime, primes
from sage.calculus.functions import jacobian
from sage.categories.fields import Fields
from sage.categories.finite_fields import FiniteFields
from sage.categories.function_fields import FunctionFields
from sage.categories.number_fields import NumberFields
from sage.categories.homset import End
from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem
from sage.misc.functional import sqrt
from sage.categories.number_fields import NumberFields
from sage.functions.other import ceil
from sage.libs.pari.all import PariError
from sage.matrix.constructor import matrix, identity_matrix
from sage.misc.cachefunc import cached_method
from sage.misc.classcall_metaclass import typecall
from sage.misc.functional import sqrt
from sage.misc.mrange import xmrange
from sage.modules.free_module_element import vector
from sage.rings.integer import Integer
from sage.arith.misc import GCD as gcd
from sage.arith.functions import lcm
from sage.arith.misc import next_prime
from sage.arith.misc import binomial
from sage.arith.misc import primes
from sage.arith.misc import moebius
from sage.categories.finite_fields import FiniteFields
from sage.parallel.ncpus import ncpus
from sage.parallel.use_fork import p_iter_fork
from sage.rings.algebraic_closure_finite_field import AlgebraicClosureFiniteField_generic
from sage.rings.complex_mpfr import ComplexField
from sage.rings.finite_rings.finite_field_constructor import (is_FiniteField, GF,
Expand All @@ -83,6 +83,7 @@ class initialization directly.
from sage.rings.fraction_field import (FractionField, is_FractionField, FractionField_1poly_field)
from sage.rings.fraction_field_element import is_FractionFieldElement, FractionFieldElement
from sage.rings.function_field.function_field import is_FunctionField
from sage.rings.integer import Integer
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.flatten import FlatteningMorphism, UnflatteningMorphism
from sage.rings.morphism import RingHomomorphism_im_gens
Expand All @@ -94,31 +95,27 @@ class initialization directly.
from sage.rings.qqbar import QQbar, number_field_elements_from_algebraics
from sage.rings.quotient_ring import QuotientRing_generic
from sage.rings.rational_field import QQ
import sage.rings.abc
from sage.rings.real_mpfr import RealField
from sage.schemes.generic.morphism import SchemeMorphism_polynomial
from sage.schemes.projective.projective_subscheme import AlgebraicScheme_subscheme_projective
from sage.schemes.product_projective.space import is_ProductProjectiveSpaces
from sage.schemes.projective.projective_morphism import (
SchemeMorphism_polynomial_projective_space,
SchemeMorphism_polynomial_projective_space_field,
SchemeMorphism_polynomial_projective_space_finite_field)
from sage.schemes.projective.projective_space import (ProjectiveSpace,
is_ProjectiveSpace)
from sage.schemes.product_projective.space import is_ProductProjectiveSpaces
from sage.schemes.projective.projective_space import ProjectiveSpace, is_ProjectiveSpace
from sage.schemes.projective.projective_subscheme import AlgebraicScheme_subscheme_projective
from sage.structure.element import get_coercion_model
from sage.symbolic.constants import e
from copy import copy
from sage.parallel.ncpus import ncpus
from sage.parallel.use_fork import p_iter_fork
from sage.dynamics.arithmetic_dynamics.projective_ds_helper import (_fast_possible_periods,_all_periodic_points)
from itertools import count, product

from .endPN_automorphism_group import (
automorphism_group_QQ_CRT,
automorphism_group_QQ_fixedpoints,
conjugating_set_helper,
conjugating_set_initializer,
is_conjugate_helper)
from .endPN_automorphism_group import automorphism_group_FF
from .generic_ds import DynamicalSystem
from .projective_ds_helper import _fast_possible_periods, _all_periodic_points


class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space,
Expand Down
18 changes: 9 additions & 9 deletions src/sage/lfunctions/zero_sums.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ AUTHORS:
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.structure.sage_object cimport SageObject
from sage.rings.integer_ring import ZZ
from sage.rings.real_double import RDF
from sage.rings.complex_double import CDF
from sage.rings.infinity import PlusInfinity
from sage.arith.misc import prime_powers
from sage.arith.misc import next_prime
from sage.arith.misc import next_prime, prime_powers
from sage.functions.log import log, exp
from sage.functions.other import real, imag
from sage.symbolic.constants import pi, euler_gamma
from sage.libs.flint.ulong_extras cimport n_is_prime
from sage.libs.pari.all import pari
from sage.misc.verbose import verbose
from sage.parallel.decorate import parallel
from sage.parallel.ncpus import ncpus as num_cpus
from sage.libs.flint.ulong_extras cimport n_is_prime
from sage.rings.complex_double import CDF
from sage.rings.infinity import PlusInfinity
from sage.rings.integer_ring import ZZ
from sage.rings.real_double import RDF
from sage.structure.sage_object cimport SageObject
from sage.symbolic.constants import euler_gamma, pi


cdef extern from "<math.h>":
double c_exp "exp"(double)
Expand Down
8 changes: 2 additions & 6 deletions src/sage/quadratic_forms/count_local_2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ r"""
Optimised Cython code for counting congruence solutions
"""

from sage.arith.misc import valuation
from sage.arith.misc import kronecker as kronecker_symbol
from sage.arith.misc import is_prime
from sage.arith.misc import is_prime, kronecker as kronecker_symbol, valuation
from sage.rings.finite_rings.integer_mod cimport IntegerMod_gmp
from sage.rings.finite_rings.integer_mod import Mod
from sage.rings.finite_rings.integer_mod_ring import IntegerModRing

from sage.rings.integer_ring import ZZ

from sage.rings.finite_rings.integer_mod cimport IntegerMod_gmp
from sage.sets.set import Set


Expand Down
15 changes: 8 additions & 7 deletions src/sage/quadratic_forms/quadratic_form__equivalence_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
- Anna Haensch (2014-12-01): added test for rational isometry
"""
from sage.arith.misc import hilbert_symbol
from sage.arith.misc import prime_divisors
from sage.arith.misc import is_prime
from sage.arith.misc import valuation
from sage.arith.misc import GCD
from sage.arith.misc import legendre_symbol

from sage.arith.misc import (hilbert_symbol,
GCD,
is_prime,
legendre_symbol,
prime_divisors,
valuation)
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ

from sage.quadratic_forms.quadratic_form import is_QuadraticForm
from .quadratic_form import is_QuadraticForm


##############################################################################
Expand Down
3 changes: 1 addition & 2 deletions src/sage/quadratic_forms/quadratic_form__genus.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
# #
#############################################################

from sage.arith.misc import is_prime, prime_divisors
from sage.quadratic_forms.genera.genus import Genus, LocalGenusSymbol
from sage.rings.integer_ring import ZZ
from sage.arith.misc import is_prime
from sage.arith.misc import prime_divisors


def global_genus_symbol(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
# places, is_semi_definite, and support for number fields.
###########################################################################


from copy import deepcopy
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.real_mpfr import RR
from sage.arith.misc import prime_divisors
from sage.arith.misc import hilbert_symbol

from sage.arith.misc import hilbert_symbol, prime_divisors
from sage.functions.all import sgn
from sage.matrix.matrix_space import MatrixSpace
from sage.misc.cachefunc import cached_method
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.real_mpfr import RR


def rational_diagonal_form(self, return_matrix=False):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from __future__ import annotations
from copy import deepcopy

from sage.arith.misc import prime_divisors
from sage.arith.misc import valuation
from sage.arith.misc import is_square
from sage.arith.misc import is_square, prime_divisors, valuation
from sage.misc.functional import numerator, denominator
from sage.quadratic_forms.extras import least_quadratic_nonresidue
from sage.rings.infinity import infinity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
"""
Conway-Sloane masses
"""
from sage.arith.misc import (fundamental_discriminant,
is_prime,
kronecker as kronecker_symbol,
legendre_symbol,
prime_divisors)
from sage.misc.misc_c import prod
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.arith.misc import kronecker as kronecker_symbol
from sage.arith.misc import legendre_symbol
from sage.arith.misc import prime_divisors
from sage.arith.misc import is_prime
from sage.arith.misc import fundamental_discriminant
from sage.symbolic.constants import pi
from sage.misc.misc_c import prod
from sage.quadratic_forms.special_values import gamma__exact, zeta__exact, quadratic_L_function__exact

from .special_values import gamma__exact, zeta__exact, quadratic_L_function__exact


def parity(self, allow_rescaling_flag=True):
Expand Down
Loading

0 comments on commit 28760be

Please sign in to comment.