Skip to content

Commit

Permalink
Trac #33007: Remove imports from sage.interfaces.all
Browse files Browse the repository at this point in the history
URL: https://trac.sagemath.org/33007
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): Frédéric Chapoton
  • Loading branch information
Release Manager committed Feb 12, 2022
2 parents 57fe9e6 + 584d121 commit 46cc022
Show file tree
Hide file tree
Showing 28 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/sage/coding/linear_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class should inherit from this class. Also ``AbstractLinearCode`` should never
from copy import copy

from sage.cpython.string import bytes_to_str
from sage.interfaces.all import gap
from sage.interfaces.gap import gap
from sage.categories.cartesian_product import cartesian_product
from sage.categories.fields import Fields
from sage.matrix.matrix_space import MatrixSpace
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/abelian_gps/abelian_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ def __init__(self, ambient, gens, names="f", category=None):
sage: G.subgroup([prod(g^k for g,k in zip(G.gens(),[1,-2,3,-4,5]))])
Multiplicative Abelian subgroup isomorphic to Z generated by {f0*f1^-2*f2^3*f3^-4*f4}
"""
from sage.interfaces.all import gap
from sage.interfaces.gap import gap
if not isinstance(ambient, AbelianGroup_class):
raise TypeError("ambient (=%s) must be an abelian group."%ambient)
if not isinstance(gens, tuple):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/abelian_gps/dual_abelian_group_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def word_problem(self, words, display=True):
## First convert the problem to one using AbelianGroups
import copy
from sage.groups.abelian_gps.abelian_group import AbelianGroup
from sage.interfaces.all import gap
from sage.interfaces.gap import gap
M = self.parent()
G = M.group()
gens = M.variable_names()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/perm_gps/cubegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
from sage.structure.richcmp import richcmp, richcmp_method

from sage.rings.real_double import RDF
from sage.interfaces.all import gap
from sage.interfaces.gap import gap
from sage.groups.perm_gps.permgroup_element import PermutationGroupElement
from sage.plot.polygon import polygon
from sage.plot.text import text
Expand Down
2 changes: 1 addition & 1 deletion src/sage/interfaces/magma.py
Original file line number Diff line number Diff line change
Expand Up @@ -2984,7 +2984,7 @@ def __init__(self, magma=None):
0
"""
if magma is None:
from sage.interfaces.all import magma as magma_default
from sage.interfaces.magma import magma as magma_default
magma = magma_default

self.magma = magma
Expand Down
2 changes: 1 addition & 1 deletion src/sage/interfaces/singular.py
Original file line number Diff line number Diff line change
Expand Up @@ -2654,7 +2654,7 @@ def __init__(self, singular=None):
it manually.
"""
if singular is None:
from sage.interfaces.all import singular as singular_default
from sage.interfaces.singular import singular as singular_default
singular = singular_default
self.singular = singular

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from sage.misc.misc import cputime
from cysignals.alarm import AlarmInterrupt, alarm, cancel_alarm

from sage.interfaces.all import magma
from sage.interfaces.magma import magma

verbose = False

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix1.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ cdef class Matrix(Matrix0):
Tries to coerce this matrix to a singular matrix.
"""
if singular is None:
from sage.interfaces.all import singular as singular_default
from sage.interfaces.singular import singular as singular_default
singular = singular_default
try:
self.base_ring()._singular_(singular)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matrix/matrix_integer_dense_hnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ def benchmark_magma_hnf(nrange, bits=4):
('magma', 50, 32, ...),
('magma', 100, 32, ...),
"""
from sage.interfaces.all import magma
from sage.interfaces.magma import magma
b = 2**bits
for n in nrange:
a = magma('MatrixAlgebra(IntegerRing(),%s)![Random(%s,%s) : i in [1..%s]]' % (n, -b, b, n**2))
Expand Down Expand Up @@ -1256,7 +1256,7 @@ def sanity_checks(times=50, n=8, m=5, proof=True, stabilize=2,
0 1 2 3 4 (done)
"""
if check_using_magma:
from sage.interfaces.all import magma
from sage.interfaces.magma import magma

def __do_check(v):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modular/btquotients/btquotient.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
from sage.quadratic_forms.all import QuadraticForm
from sage.graphs.all import Graph
from sage.libs.all import pari
from sage.interfaces.all import magma
from sage.interfaces.magma import magma
from sage.plot.colors import rainbow
from sage.rings.number_field.all import NumberField
from sage.modular.arithgroup.all import Gamma0
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modular/quatalg/brandt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ def benchmark_magma(levels, silent=False):
('magma', 97, 2, ...)
"""
ans = []
from sage.interfaces.all import magma
from sage.interfaces.magma import magma
for p, M in levels:
t = magma.cputime()
magma.eval('HeckeOperator(BrandtModule(%s, %s),2)' % (p, M))
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 @@ -224,7 +224,7 @@
# ****************************************************************************
from sage.misc.cachefunc import cached_method

from sage.interfaces.all import singular
from sage.interfaces.singular import singular

from sage.arith.all import lcm

Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/integer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3929,9 +3929,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
sort=False, simplify=False)
elif algorithm in ['kash', 'magma']:
if algorithm == 'kash':
from sage.interfaces.all import kash as I
from sage.interfaces.kash import kash as I
else:
from sage.interfaces.all import magma as I
from sage.interfaces.magma import magma as I
str_res = I.eval('Factorization(%s)'%n)
# The result looks like "[ <n1, p1>, <p2, e2>, ... ]
str_res = str_res.replace(']', '').replace('[', '').replace('>', '').replace('<', '').split(',')
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/multi_polynomial_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.interfaces.all import (singular as singular_default,
magma as magma_default)
from sage.interfaces.singular import singular as singular_default
from sage.interfaces.magma import magma as magma_default

from sage.interfaces.expect import StdOutContext

Expand Down
1 change: 0 additions & 1 deletion src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ from sage.structure.richcmp cimport rich_to_bool, richcmp
from sage.structure.factorization import Factorization
from sage.structure.sequence import Sequence

from sage.interfaces.all import macaulay2
from sage.interfaces.singular import singular as singular_default, is_SingularElement, SingularElement
from sage.interfaces.macaulay2 import macaulay2 as macaulay2_default, is_Macaulay2Element

Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/pbori/pbori.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ from sage.categories.action cimport Action
from sage.monoids.monoid import Monoid_class

from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.interfaces.all import singular as singular_default
from sage.interfaces.singular import singular as singular_default
from sage.interfaces.singular import SingularElement

order_dict = {"lp": pblp,
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import sage.rings.polynomial.polynomial_ring
from sage.rings.infinity import infinity

from . import polynomial_singular_interface
from sage.interfaces.all import singular as singular_default
from sage.interfaces.singular import singular as singular_default

from sage.structure.element import coerce_binop

Expand Down
6 changes: 3 additions & 3 deletions src/sage/rings/polynomial/polynomial_rational_flint.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ from sage.libs.flint.fmpq cimport *
from sage.libs.flint.fmpz_poly cimport *
from sage.libs.flint.fmpq_poly cimport *

from sage.interfaces.all import singular as singular_default
from sage.interfaces.singular import singular as singular_default

from cypari2.gen import Gen as pari_gen

Expand Down Expand Up @@ -2192,7 +2192,7 @@ cdef class Polynomial_rational_flint(Polynomial):

elif algorithm == 'kash':
try:
from sage.interfaces.all import kash
from sage.interfaces.kash import kash
kash.eval('X := PolynomialRing(RationalField()).1')
s = self._repr(name='X')
G = kash('Galois(%s)'%s)
Expand All @@ -2217,7 +2217,7 @@ cdef class Polynomial_rational_flint(Polynomial):
return TransitiveGroup(self.degree(), fgap.GaloisType())

elif algorithm == 'magma':
from sage.interfaces.all import magma
from sage.interfaces.magma import magma
X = magma(self).GaloisGroup()
try:
n, d = X.TransitiveGroupIdentification(nvals=2)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/polynomial_singular_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import sage.rings.abc
import sage.rings.number_field as number_field

from sage.interfaces.all import singular
from sage.interfaces.singular import singular
from sage.rings.rational_field import is_RationalField
from sage.rings.function_field.function_field import RationalFunctionField
from sage.rings.finite_rings.finite_field_base import is_FiniteField
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/polynomial_template.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ from sage.libs.all import pari_gen

import operator

from sage.interfaces.all import singular as singular_default
from sage.interfaces.singular import singular as singular_default

def make_element(parent, args):
return parent(*args)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/affine/affine_subscheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# ****************************************************************************

from sage.categories.fields import Fields
from sage.interfaces.all import singular
from sage.interfaces.singular import singular
from sage.modules.free_module_element import vector
from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_subscheme

Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/curves/affine_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
from sage.misc.cachefunc import cached_method

from sage.arith.misc import binomial
from sage.interfaces.all import singular
from sage.interfaces.singular import singular
from builtins import sum as add

from sage.categories.fields import Fields
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/curves/projective_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
from sage.categories.number_fields import NumberFields
from sage.categories.homset import Hom, End

from sage.interfaces.all import singular
from sage.interfaces.singular import singular
from sage.matrix.constructor import matrix
from builtins import sum as add
from sage.misc.sage_eval import sage_eval
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/elliptic_curves/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.interfaces.all import magma
from sage.interfaces.magma import magma
from sage.rings.all import (Integer,
QQ,
ZZ,
Expand Down
12 changes: 6 additions & 6 deletions src/sage/schemes/elliptic_curves/ell_rational_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
from sage.libs.pari.all import pari
from sage.functions.gamma import gamma_inc
from math import sqrt
from sage.interfaces.all import gp
from sage.interfaces.gp import gp
from sage.misc.cachefunc import cached_method
from copy import copy

Expand Down Expand Up @@ -471,9 +471,9 @@ def mwrank(self, options=''):
Regulator = 95.98037...
"""
if not options:
from sage.interfaces.all import mwrank
from sage.interfaces.mwrank import mwrank
else:
from sage.interfaces.all import Mwrank
from sage.interfaces.mwrank import Mwrank
mwrank = Mwrank(options=options)
return mwrank(list(self.a_invariants()))

Expand Down Expand Up @@ -1544,7 +1544,7 @@ def analytic_rank(self, algorithm="pari", leading_coefficient=False):
elif algorithm == 'magma':
if leading_coefficient:
raise NotImplementedError("Cannot compute leading coefficient using magma")
from sage.interfaces.all import magma
from sage.interfaces.magma import magma
return rings.Integer(magma(self).AnalyticRank())
elif algorithm == 'zero_sum':
if leading_coefficient:
Expand Down Expand Up @@ -1970,7 +1970,7 @@ def three_selmer_rank(self, algorithm='UseSUnits'):
sage: EllipticCurve('681b').three_selmer_rank(algorithm='Heuristic') # long time (10 seconds); optional - magma
2
"""
from sage.interfaces.all import magma
from sage.interfaces.magma import magma
E = magma(self)
return Integer(E.ThreeSelmerGroup(MethodForFinalStep = magma('"%s"'%algorithm)).Ngens())

Expand Down Expand Up @@ -3753,7 +3753,7 @@ def modular_degree(self, algorithm='sympow', M=1):
from sage.lfunctions.all import sympow
m = sympow.modular_degree(self)
elif algorithm == 'magma':
from sage.interfaces.all import magma
from sage.interfaces.magma import magma
m = rings.Integer(magma(self).ModularDegree())
else:
raise ValueError("unknown algorithm %s"%algorithm)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/elliptic_curves/lseries_ell.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def dokchitser(self, prec=53,
algorithm = 'pari'

if algorithm == 'magma':
from sage.interfaces.all import magma
from sage.interfaces.magma import magma
return magma(self.__E).LSeries(Precision=prec)

if algorithm == 'pari':
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/hyperelliptic_curves/mestre.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def HyperellipticCurve_from_invariants(i, reduced=True, precision=None,
t = k['t'].gen()

if algorithm == 'magma':
from sage.interfaces.all import magma
from sage.interfaces.magma import magma
from sage.misc.sage_eval import sage_eval
if MConic.has_rational_point(algorithm='magma'):
parametrization = [l.replace('$.1', 't').replace('$.2', 'u') \
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/projective/projective_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

from sage.arith.all import gcd, lcm

from sage.interfaces.all import singular
from sage.interfaces.singular import singular

from sage.misc.misc_c import prod
from sage.misc.cachefunc import cached_method
Expand Down

0 comments on commit 46cc022

Please sign in to comment.