Skip to content

Commit

Permalink
Trac #34947: sage.{rings,modules,geometry}: Replace imports from sage…
Browse files Browse the repository at this point in the history
….*.all for namespace packages

Using `./sage -fiximports` from #34945.

Also remove trailing whitespace in the affected files.

Part of Meta-ticket #32414

URL: https://trac.sagemath.org/34947
Reported by: mkoeppe
Ticket author(s): Alex Chandler
Reviewer(s): Travis Scrimshaw, Matthias Koeppe
  • Loading branch information
Release Manager committed Feb 11, 2023
2 parents 2cd6166 + 9a212f4 commit 67eab0a
Show file tree
Hide file tree
Showing 74 changed files with 191 additions and 148 deletions.
3 changes: 2 additions & 1 deletion src/sage/geometry/cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@
from copy import copy
from warnings import warn

from sage.arith.all import gcd, lcm
from sage.arith.misc import GCD as gcd
from sage.arith.functions import lcm
from sage.combinat.posets.posets import FinitePoset
from sage.geometry.point_collection import PointCollection
from sage.geometry.polyhedron.constructor import Polyhedron
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/hyperplane_arrangement/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from sage.combinat.combinat import stirling_number2
from sage.combinat.root_system.cartan_type import CartanType
from sage.combinat.root_system.root_system import RootSystem
from sage.arith.all import binomial
from sage.arith.misc import binomial
from sage.rings.polynomial.polynomial_ring import polygen

from sage.geometry.hyperplane_arrangement.arrangement import HyperplaneArrangements
Expand Down
3 changes: 2 additions & 1 deletion src/sage/geometry/integral_points.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.real_mpfr import RR
from sage.rings.integer cimport Integer
from sage.arith.all import gcd, lcm
from sage.arith.misc import GCD as gcd
from sage.arith.functions import lcm
from sage.combinat.permutation import Permutation
from sage.misc.misc_c import prod
from sage.modules.free_module import FreeModule
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/lattice_polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.arith.all import gcd
from sage.arith.misc import GCD as gcd
from sage.combinat.posets.posets import FinitePoset
from sage.env import POLYTOPE_DATA_DIR
from sage.geometry.cone import _ambient_space_point, integral_length
Expand Down
12 changes: 6 additions & 6 deletions src/sage/geometry/point_collection.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -955,23 +955,23 @@ def read_palp_point_collection(f, lattice=None, permutation=False):
Read and return a point collection from an opened file.
Data must be in PALP format:
* the first input line starts with two integers `m` and `n`, the number
of points and the number of components of each;
* the rest of the first line may contain a permutation;
* the next `m` lines contain `n` numbers each.
.. NOTE::
If `m` < `n`, it is assumed (for compatibility with PALP) that the
matrix is transposed, i.e. that each column is a point.
INPUT:
- ``f`` -- an opened file with PALP output.
- ``lattice`` -- the lattice for points. If not given, the
:class:`toric lattice <sage.geometry.toric_lattice.ToricLatticeFactory>`
`M` of dimension `n` will be used.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/polyhedron/generating_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ def generate_mods(equations):
sage: _TransformMod.generate_mods([(0, 1, 1, -2)])
({0: (2, 0), 1: (2, 0)}, {0: (2, 1), 1: (2, 1)})
"""
from sage.arith.all import lcm
from sage.arith.functions import lcm
from sage.matrix.constructor import matrix
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/triangulation/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ def normal_cone(self):
raise NotImplementedError('Only base rings ZZ and QQ are supported')
from ppl import Constraint_System, Linear_Expression, C_Polyhedron
from sage.matrix.constructor import matrix
from sage.arith.all import lcm
from sage.arith.functions import lcm
pc = self.point_configuration()
cs = Constraint_System()
for facet in self.interior_facets():
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/fg_pid/fgp_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def additive_order(self):
from sage.rings.infinity import infinity
from sage.rings.finite_rings.integer_mod import Mod
from sage.rings.integer import Integer
from sage.arith.all import lcm
from sage.arith.functions import lcm
n = Integer(1)
for i, a in enumerate(I):
if a == 0:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/fg_pid/fgp_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def __init__(self, X, Y, category=None):
from sage.categories.modules_with_basis import ModulesWithBasis
category = ModulesWithBasis(X.base_ring())
else:
from sage.categories.all import Modules
from sage.categories.modules import Modules
category = Modules(X.base_ring())
Homset.__init__(self, X, Y, category)

Expand Down
6 changes: 5 additions & 1 deletion src/sage/modules/filtered_vector_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@
# https://www.gnu.org/licenses/
# ***************************************************************************

from sage.rings.all import QQ, ZZ, RDF, RR, Integer
from sage.rings.rational_field import QQ
from sage.rings.integer_ring import ZZ
from sage.rings.real_double import RDF
from sage.rings.real_mpfr import RR
from sage.rings.integer import Integer
from sage.rings.infinity import InfinityRing, infinity, minus_infinity
from sage.categories.fields import Fields
from sage.modules.free_module import FreeModule_ambient_field, VectorSpace
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/free_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -6718,7 +6718,7 @@ def _denominator(self, B):
if not B:
return 1
d = B[0].denominator()
from sage.arith.all import lcm
from sage.arith.functions import lcm
for x in B[1:]:
d = lcm(d,x.denominator())
return d
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/free_module_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ cdef class FreeModuleElement(Vector): # abstract base class
if isinstance(ord, AnInfinity):
return ord
v.append(ord)
from sage.arith.all import lcm
from sage.arith.functions import lcm
return lcm(v)

def items(self):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/module.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ cdef class Module(Parent):
sage: M.endomorphism_ring()
Set of Morphisms from <sage.modules.module.Module object at ...> to <sage.modules.module.Module object at ...> in Category of modules over Integer Ring
"""
from sage.categories.all import End
from sage.categories.homset import End
return End(self)

def is_Module(x):
Expand Down
4 changes: 3 additions & 1 deletion src/sage/modules/multi_filtered_vector_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.rings.all import QQ, ZZ, Integer
from sage.rings.rational_field import QQ
from sage.rings.integer_ring import ZZ
from sage.rings.integer import Integer
from sage.rings.infinity import infinity, minus_infinity
from sage.categories.fields import Fields
from sage.modules.free_module import FreeModule_ambient_field, VectorSpace
Expand Down
5 changes: 4 additions & 1 deletion src/sage/modules/torsion_quadratic_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
from sage.modules.fg_pid.fgp_element import FGP_Element
from sage.modules.free_quadratic_module import FreeQuadraticModule
from sage.arith.misc import gcd
from sage.rings.all import ZZ, Zp, QQ, IntegerModRing
from sage.rings.integer_ring import ZZ
from sage.rings.padics.factory import Zp
from sage.rings.rational_field import QQ
from sage.rings.finite_rings.integer_mod_ring import IntegerModRing
from sage.groups.additive_abelian.qmodnz import QmodnZ
from sage.matrix.constructor import matrix
from sage.matrix.special import diagonal_matrix
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/with_basis/cell_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#*****************************************************************************

from sage.misc.cachefunc import cached_method
from sage.categories.all import ModulesWithBasis
from sage.categories.modules_with_basis import ModulesWithBasis
from sage.structure.element import Element
from sage.combinat.free_module import CombinatorialFreeModule
from sage.data_structures.blas_dict import linear_combination
Expand Down
4 changes: 3 additions & 1 deletion src/sage/modules/with_basis/indexed_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ from sage.misc.lazy_attribute import lazy_attribute
from sage.misc.superseded import deprecation
from sage.typeset.ascii_art import AsciiArt, empty_ascii_art, ascii_art
from sage.typeset.unicode_art import UnicodeArt, empty_unicode_art, unicode_art
from sage.categories.all import Category, Sets, ModulesWithBasis
from sage.categories.category import Category
from sage.categories.sets_cat import Sets
from sage.categories.modules_with_basis import ModulesWithBasis
from sage.data_structures.blas_dict cimport add, negate, scal, axpy


Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/with_basis/subquotient.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sage.sets.family import Family
from sage.combinat.free_module import CombinatorialFreeModule
from sage.misc.lazy_attribute import lazy_attribute
from sage.categories.all import ModulesWithBasis
from sage.categories.modules_with_basis import ModulesWithBasis


class QuotientModuleWithBasis(CombinatorialFreeModule):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/algebraic_closure_finite_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ def _roots_univariate_polynomial(self, p, ring=None, multiplicities=None, algori
....: assert p(r).is_zero(), "r={} is not a root of p={}".format(r,p)
"""
from sage.arith.all import lcm
from sage.arith.functions import lcm
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing

# first build a polynomial over some finite field
Expand Down
6 changes: 3 additions & 3 deletions src/sage/rings/asymptotic/asymptotic_expansion_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def _log_StirlingNegativePowers_(var, precision):
return A.zero()
n = A.gen()

from sage.arith.all import bernoulli
from sage.arith.misc import bernoulli
from sage.arith.srange import srange

result = sum((bernoulli(k) / k / (k-1) / n**(k-1)
Expand Down Expand Up @@ -462,7 +462,7 @@ def HarmonicNumber(var, precision=None, skip_constant_summand=False):
result += 1 / (2 * n)

from sage.arith.srange import srange
from sage.arith.all import bernoulli
from sage.arith.misc import bernoulli
for k in srange(2, 2*precision - 4, 2):
result += -bernoulli(k) / k / n**k

Expand Down Expand Up @@ -912,7 +912,7 @@ def SingularityAnalysis(var, zeta=1, alpha=0, beta=0, delta=0,
from .asymptotic_ring import AsymptoticRing
from .growth_group import ExponentialGrowthGroup, \
MonomialGrowthGroup, GenericNonGrowthGroup
from sage.arith.all import falling_factorial
from sage.arith.misc import falling_factorial
from sage.categories.cartesian_product import cartesian_product
from sage.functions.other import binomial
from sage.functions.gamma import gamma
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ def cohomology_decomposition(self):
(1/3, [(x*y - 1, 1), (x^2 + y^2 - 1, 1)])
"""
from sage.calculus.functions import jacobian
from sage.arith.all import xgcd
from sage.arith.misc import XGCD as xgcd
from sage.sets.set import Set

R = self.denominator_ring
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/cfinite_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ def closed_form(self, n='n'):
sage: CFiniteSequence((x/(1-x-x^2))^2).closed_form()
1/5*(n - sqrt(1/5))*(1/2*sqrt(5) + 1/2)^n + 1/5*(n + sqrt(1/5))*(-1/2*sqrt(5) + 1/2)^n
"""
from sage.arith.all import binomial
from sage.arith.misc import binomial
from sage.rings.qqbar import QQbar

from sage.symbolic.ring import SR
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/complex_double.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2482,7 +2482,7 @@ cdef class ComplexDoubleElement(FieldElement):
sage: CDF(1,5).algdep(2)
x^2 - 2*x + 26
"""
from sage.arith.all import algdep
from sage.arith.misc import algdep
return algdep(self, n)

cdef class FloatToCDF(Morphism):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/complex_mpc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement):
sage: p(z)
1.11022302462516e-16
"""
from sage.arith.all import algdep
from sage.arith.misc import algdep
return algdep(self, n, **kwds)

################################
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/complex_mpfr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3279,7 +3279,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement):
sage: p(z)
1.11022302462516e-16
"""
from sage.arith.all import algdep
from sage.arith.misc import algdep
return algdep(self, n, **kwds)

# Alias
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/factorint.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ cpdef aurifeuillian(n, m, F=None, bint check=True):
There is no need to set `F`. It's only for increasing speed
of :meth:`factor_aurifeuillian()`.
"""
from sage.arith.all import euler_phi
from sage.arith.misc import euler_phi
from sage.rings.real_mpfi import RealIntervalField
if check:
if not n.is_squarefree():
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/fast_arith.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ cpdef prime_range(start, stop=None, algorithm=None, bint py_ints=False):
res = pari_prime_range(start, stop, py_ints)

elif (algorithm == "pari_isprime") or (algorithm == "pari_primes"):
from sage.arith.all import primes
from sage.arith.misc import primes
res = list(primes(start, stop))
else:
raise ValueError('algorithm must be "pari_primes" or "pari_isprime"')
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/finite_rings/finite_field_base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ cdef class FiniteField(Field):
a + 12
"""
if self.degree() == 1:
from sage.arith.all import primitive_root
from sage.arith.misc import primitive_root
return self(primitive_root(self.order()))
F, = self.factored_unit_order()
return self._element_of_factored_order(F)
Expand Down
7 changes: 4 additions & 3 deletions src/sage/rings/finite_rings/integer_mod.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ from sage.misc.persist import register_unpickle_override

from sage.structure.parent cimport Parent

from sage.arith.all import crt, lcm
from sage.arith.misc import CRT as crt
from sage.arith.functions import lcm
from sage.groups.generic import discrete_log


Expand Down Expand Up @@ -1298,7 +1299,7 @@ cdef class IntegerMod_abstract(FiniteRingElement):
vmod.append(w)
moduli.append(k)
# Now combine in all possible ways using the CRT
from sage.arith.all import CRT_basis
from sage.arith.misc import CRT_basis
basis = CRT_basis(moduli)
from sage.misc.mrange import cartesian_product_iterator
v = []
Expand Down Expand Up @@ -4464,7 +4465,7 @@ cdef class IntegerMod_to_Integer(Map):
Set of Morphisms from Finite Field of size 2 to Integer Ring in Category of sets
"""
import sage.categories.homset
from sage.categories.all import Sets
from sage.categories.sets_cat import Sets
Morphism.__init__(self, sage.categories.homset.Hom(R, integer_ring.ZZ, Sets()))

cpdef Element _call_(self, x):
Expand Down
4 changes: 3 additions & 1 deletion src/sage/rings/finite_rings/integer_mod_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@

import sage.misc.prandom as random

from sage.arith.all import factor, primitive_root, CRT_basis
from sage.arith.misc import factor
from sage.arith.misc import primitive_root
from sage.arith.misc import CRT_basis
import sage.rings.ring as ring
import sage.rings.abc
from . import integer_mod
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/finite_rings/residue_field.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ cdef class ReductionMap(Map):
self._PBinv = PBinv
self._to_order = to_order # used for lift
self._PB = PB # used for lift
from sage.categories.all import SetsWithPartialMaps
from sage.categories.sets_with_partial_maps import SetsWithPartialMaps
self._repr_type_str = "Partially defined reduction"
Map.__init__(self, Hom(K, F, SetsWithPartialMaps()))

Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/fraction_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ def section(self):
"""
from sage.categories.sets_with_partial_maps import SetsWithPartialMaps
from sage.categories.all import Hom
from sage.categories.homset import Hom
parent = Hom(self.codomain(), self.domain(), SetsWithPartialMaps())
return parent.__make_element_class__(FractionFieldEmbeddingSection)(self)

Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/divisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
from sage.misc.cachefunc import cached_method
from sage.misc.latex import latex

from sage.arith.all import lcm
from sage.arith.functions import lcm

from sage.structure.unique_representation import UniqueRepresentation
from sage.structure.parent import Parent
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/function_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@

from sage.interfaces.singular import singular

from sage.arith.all import lcm
from sage.arith.functions import lcm

from sage.rings.integer import Integer
from sage.rings.ring import Field
Expand Down
3 changes: 2 additions & 1 deletion src/sage/rings/function_field/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@
from sage.misc.cachefunc import cached_method

from sage.modules.free_module_element import vector
from sage.arith.all import lcm, gcd
from sage.arith.functions import lcm
from sage.arith.misc import GCD as gcd

from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.algebras.all import FiniteDimensionalAlgebra
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/place.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

from sage.misc.cachefunc import cached_method

from sage.arith.all import lcm
from sage.arith.functions import lcm

from sage.rings.integer_ring import ZZ
from sage.rings.qqbar import QQbar
Expand Down
Loading

0 comments on commit 67eab0a

Please sign in to comment.