Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Jan 30, 2023
2 parents 4353e01 + 28760be commit 41bfff4
Show file tree
Hide file tree
Showing 45 changed files with 185 additions and 130 deletions.
2 changes: 1 addition & 1 deletion src/sage/arith/multi_modular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ from cysignals.memory cimport check_allocarray, check_reallocarray, sig_free

from sage.libs.gmp.mpz cimport *
from sage.rings.integer cimport Integer, smallInteger
from sage.arith.all import random_prime
from sage.arith.misc import random_prime
from types import GeneratorType
from sage.ext.stdsage cimport PY_NEW
from cpython.object cimport PyObject_RichCompare
Expand Down
4 changes: 3 additions & 1 deletion src/sage/arith/numerical_approx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Generic numerical approximation function
from sage.structure.parent cimport Parent
from sage.structure.element cimport parent
cdef Parent CDF
from sage.rings.all import RealField, ComplexField, CDF
from sage.rings.real_mpfr import RealField
from sage.rings.complex_mpfr import ComplexField
from sage.rings.complex_double import CDF


def numerical_approx_generic(x, prec):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/crypto/boolean_function.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ cdef class BooleanFunction(SageObject):
from sage.misc.misc_c import prod

from sage.matrix.constructor import Matrix
from sage.arith.all import binomial
from sage.arith.misc import binomial
M = Matrix(GF(2), sum(binomial(self._nvariables,i) for i in range(d+1)), len(s))

cdef long i
Expand Down
2 changes: 1 addition & 1 deletion src/sage/crypto/classical.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +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.all import xgcd, 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
2 changes: 1 addition & 1 deletion src/sage/crypto/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def gen_lattice(type='modular', n=4, m=8, q=11, seed=None,
A = A.stack(R.random_element().matrix())

elif type == 'cyclotomic':
from sage.arith.all import euler_phi
from sage.arith.misc import euler_phi
from sage.misc.functional import cyclotomic_polynomial

# we assume that n+1 <= min( euler_phi^{-1}(n) ) <= 2*n
Expand Down
3 changes: 2 additions & 1 deletion src/sage/crypto/lfsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@
import copy

from sage.structure.all import Sequence
from sage.rings.all import Integer, PolynomialRing
from sage.rings.integer import Integer
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.finite_rings.finite_field_constructor import is_FiniteField


Expand Down
14 changes: 8 additions & 6 deletions src/sage/crypto/lwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +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.all import ZZ, IntegerModRing, RR
from sage.arith.all import next_prime, euler_phi
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.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
10 changes: 5 additions & 5 deletions src/sage/crypto/public_key/blum_goldwasser.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +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.all import gcd, power_mod, 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
10 changes: 5 additions & 5 deletions src/sage/crypto/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +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.all import gcd, 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
8 changes: 5 additions & 3 deletions src/sage/crypto/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
# http://www.gnu.org/licenses/
#*****************************************************************************

from sage.arith.functions import lcm
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.arith.all import is_prime, lcm, primes, random_prime
from sage.rings.integer import Integer
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
3 changes: 2 additions & 1 deletion src/sage/databases/findstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,8 @@ def __call__(self, elt):
from sage.repl.preparse import preparse
try:
l = {}
code = "from sage.all import *\n" + preparse(self.sage_code())
environment = 'sage.all'
code = f"from {environment} import *\n" + preparse(self.sage_code())
exec(code, l)
except SyntaxError:
raise ValueError("could not execute verified code for %s" % self)
Expand Down
4 changes: 3 additions & 1 deletion src/sage/databases/jones.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@

import os

from sage.rings.all import NumberField, RationalField, PolynomialRing
from sage.rings.number_field.number_field import NumberField
from sage.rings.rational_field import RationalField
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.misc.misc import powerset
from sage.env import SAGE_SHARE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +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.all import gcd, lcm, CRT, is_square, 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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from sage.rings.rational_field import QQ
from sage.schemes.affine.affine_space import AffineSpace
from sage.symbolic.constants import e
from sage.arith.all import gcd
from sage.arith.misc import GCD as gcd
from copy import copy

def bCheck(c, v, p, b):
Expand Down
36 changes: 19 additions & 17 deletions src/sage/dynamics/arithmetic_dynamics/projective_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +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.all import gcd, lcm, next_prime, binomial, primes, 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 @@ -78,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 @@ -89,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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ AUTHORS:

from sage.arith.functions cimport LCM_list
from sage.rings.finite_rings.finite_field_constructor import GF
from sage.sets.all import Set
from sage.sets.set import Set
from sage.misc.misc import subsets

cpdef _fast_possible_periods(self, return_points=False):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ from sage.symbolic.ring import SR
from sage.calculus.var import var
from sage.rings.fraction_field import is_FractionField
from sage.categories.function_fields import FunctionFields
from sage.libs.all import PariError
from cypari2.handle_error import PariError
from math import sqrt


Expand Down Expand Up @@ -944,7 +944,7 @@ cpdef general_julia(f, double x_center=0, double y_center=0, image_width=4,
sage: from sage.dynamics.complex_dynamics.mandel_julia_helper import general_julia
sage: from sage.plot.colors import Color
sage: R.<z> = CC[]
sage: f = z^5 - 1
sage: f = z^5 - 1
sage: general_julia(f)
500x500px 24-bit RGB image
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/lfunctions/dokchitser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import string

from sage.structure.sage_object import SageObject
from sage.rings.all import ComplexField
from sage.rings.complex_mpfr import ComplexField
from sage.rings.integer import Integer
from sage.misc.sage_eval import sage_eval
from sage.misc.verbose import verbose
Expand Down
5 changes: 4 additions & 1 deletion src/sage/lfunctions/pari.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
from cypari2.gen import Gen
from sage.libs.pari import pari
from sage.structure.sage_object import SageObject
from sage.rings.all import (ZZ, RealField, ComplexField, PowerSeriesRing)
from sage.rings.integer_ring import ZZ
from sage.rings.real_mpfr import RealField
from sage.rings.complex_mpfr import ComplexField
from sage.rings.power_series_ring import PowerSeriesRing


class lfun_generic():
Expand Down
17 changes: 9 additions & 8 deletions src/sage/lfunctions/zero_sums.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +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.all import prime_powers, 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
7 changes: 4 additions & 3 deletions src/sage/quadratic_forms/binary_qf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@
from functools import total_ordering

from sage.libs.pari.all import pari_gen
from sage.rings.all import ZZ, is_fundamental_discriminant
from sage.arith.all import gcd
from sage.rings.integer_ring import ZZ
from sage.rings.number_field.number_field import is_fundamental_discriminant
from sage.arith.misc import GCD as gcd
from sage.structure.sage_object import SageObject
from sage.matrix.matrix_space import MatrixSpace
from sage.matrix.constructor import Matrix
Expand Down Expand Up @@ -1528,7 +1529,7 @@ def small_prime_value(self, Bmax=1000):
sage: [Q.small_prime_value() for Q in BinaryQF_reduced_representatives(-47, primitive_only=True)]
[47, 2, 2, 3, 3]
"""
from sage.sets.all import Set
from sage.sets.set import Set
from sage.arith.srange import xsrange
B = 10
while True:
Expand Down
Loading

0 comments on commit 41bfff4

Please sign in to comment.