diff --git a/cython/core/abelian_group.pyx b/cython/core/abelian_group.pyx index d3a19acd0..0aaeb5b89 100644 --- a/cython/core/abelian_group.pyx +++ b/cython/core/abelian_group.pyx @@ -49,7 +49,8 @@ cdef class AbelianGroup(): 'as a sequence.') int_types = [int] if _within_sage: - int_types += [sage.rings.integer.Integer] + from sage.rings.integer import Integer + int_types += [Integer] for c in self.divisors: assert type(c) in int_types and c >= 0,\ 'Elementary divisors must be non-negative integers.\n' diff --git a/cython/core/basic.pyx b/cython/core/basic.pyx index 5e9c6531f..f866e66f3 100644 --- a/cython/core/basic.pyx +++ b/cython/core/basic.pyx @@ -19,7 +19,6 @@ python_major_version = sys.version_info.major from .sage_helper import _within_sage, SageNotAvailable from .pari import pari as pari try: - import sage.all import sage.structure.sage_object from sage.groups.perm_gps.permgroup_element import is_PermutationGroupElement from sage.groups.perm_gps.permgroup import PermutationGroup diff --git a/cython/core/fundamental_group.pyx b/cython/core/fundamental_group.pyx index 750f190f1..50a7b69ae 100644 --- a/cython/core/fundamental_group.pyx +++ b/cython/core/fundamental_group.pyx @@ -477,7 +477,8 @@ class FundamentalGroup(CFundamentalGroup): if _within_sage: - FundamentalGroup.__bases__ += (sage.structure.sage_object.SageObject,) + from sage.structure.sage_object import SageObject + FundamentalGroup.__bases__ += (SageObject,) # Holonomy Groups @@ -594,4 +595,5 @@ class HolonomyGroup(CHolonomyGroup): if _within_sage: - HolonomyGroup.__bases__ += (sage.structure.sage_object.SageObject,) + from sage.structure.sage_object import SageObject + HolonomyGroup.__bases__ += (SageObject,) diff --git a/dev/drilling/smoke_test.py b/dev/drilling/smoke_test.py index a8271ad23..e669aa2f9 100644 --- a/dev/drilling/smoke_test.py +++ b/dev/drilling/smoke_test.py @@ -5,7 +5,7 @@ from snappy.drilling import exceptions from snappy.drilling import perturb -from sage.all import pi +from sage.symbolic.constants import pi # perturb._tube_developing_radius = 1 diff --git a/dev/drilling/smoke_test2.py b/dev/drilling/smoke_test2.py index 45da51eef..f448f5d41 100644 --- a/dev/drilling/smoke_test2.py +++ b/dev/drilling/smoke_test2.py @@ -5,7 +5,7 @@ from snappy.drilling import exceptions from snappy.drilling import perturb -from sage.all import pi +from sage.symbolic.constants import pi # perturb._tube_developing_radius = 1 diff --git a/python/cusps/maximal_cusp_area_matrix.py b/python/cusps/maximal_cusp_area_matrix.py index ccef94763..e3b616ea7 100644 --- a/python/cusps/maximal_cusp_area_matrix.py +++ b/python/cusps/maximal_cusp_area_matrix.py @@ -9,7 +9,7 @@ from ..hyperboloid.distances import distance_r13_horoballs if _within_sage: - import sage.all + from ..sage_helper import Infinity def maximal_cusp_area_matrix(manifold, bits_prec, verified): """ @@ -63,7 +63,7 @@ def _diagonal_scale(mcomplex, i): return e ** 2 if mcomplex.verified: - d = mcomplex.RF(sage.all.Infinity) + d = mcomplex.RF(Infinity) else: d = mcomplex.RF(1e20) @@ -93,7 +93,7 @@ def _non_diagonal_scale(mcomplex, i, j): return e ** 2 if mcomplex.verified: - d = mcomplex.RF(sage.all.Infinity) + d = mcomplex.RF(Infinity) else: d = mcomplex.RF(1e20) diff --git a/python/database.py b/python/database.py index 1082bc2ae..7d36993b5 100644 --- a/python/database.py +++ b/python/database.py @@ -22,17 +22,17 @@ import collections if _within_sage: - import sage.all + from .sage_helper import Integer, RealDoubleElement, RealNumber def is_int(slice): - return isinstance(slice, (sage.all.Integer, int)) + return isinstance(slice, (Integer, int)) def is_int_or_none(slice): - return isinstance(slice, (sage.all.Integer, int, type(None))) + return isinstance(slice, (Integer, int, type(None))) def is_float_or_none(slice): - return isinstance(slice, (float, sage.all.RealDoubleElement, - sage.rings.real_mpfr.RealNumber, type(None))) + return isinstance(slice, (float, RealDoubleElement, + RealNumber, type(None))) else: def is_int(slice): return isinstance(slice, int) diff --git a/python/exterior_to_link/rational_linear_algebra.py b/python/exterior_to_link/rational_linear_algebra.py index add928d74..c63825f29 100644 --- a/python/exterior_to_link/rational_linear_algebra.py +++ b/python/exterior_to_link/rational_linear_algebra.py @@ -17,7 +17,7 @@ from .. import sage_helper if sage_helper._within_sage and not use_pari_even_inside_sage: - from sage.all import QQ, RR, vector, matrix, VectorSpace + from ..sage_helper import QQ, RR, vector, matrix, VectorSpace def rational_sqrt(x): """ diff --git a/python/exterior_to_link/rational_linear_algebra_wrapped.py b/python/exterior_to_link/rational_linear_algebra_wrapped.py index 7f304bfd6..a58b4940b 100644 --- a/python/exterior_to_link/rational_linear_algebra_wrapped.py +++ b/python/exterior_to_link/rational_linear_algebra_wrapped.py @@ -16,7 +16,7 @@ This file is not currently used by SnapPy, but is kept for possible future reference. """ -from sage.all import QQ, vector, matrix, VectorSpace +from ..sage_helper import QQ, vector, matrix, VectorSpace class Vector: diff --git a/python/geometric_structure/cusp_neighborhood/complex_cusp_cross_section.py b/python/geometric_structure/cusp_neighborhood/complex_cusp_cross_section.py index f6d4db364..40bdf5a89 100644 --- a/python/geometric_structure/cusp_neighborhood/complex_cusp_cross_section.py +++ b/python/geometric_structure/cusp_neighborhood/complex_cusp_cross_section.py @@ -384,7 +384,8 @@ def _add_one_cusp_vertex_positions(self, cusp : t3m.Vertex): visited.add((tet1.Index, vert1)) def _debug_show_horotriangles(self, cusp : int =0): - from sage.all import line, real, imag + from sage.plot.line import line + from sage.functions.other import real, imag self.add_vertex_positions_to_horotriangles() @@ -398,7 +399,8 @@ def _debug_show_horotriangles(self, cusp : int =0): if tet.Class[V].Index == cusp ]) def _debug_show_lifted_horotriangles(self, cusp : int =0): - from sage.all import line, real, imag + from sage.plot.line import line + from sage.functions.other import real, imag self.add_vertex_positions_to_horotriangles() diff --git a/python/hyperboloid/distances.py b/python/hyperboloid/distances.py index ebbc467c3..56f313e74 100644 --- a/python/hyperboloid/distances.py +++ b/python/hyperboloid/distances.py @@ -8,7 +8,7 @@ from ..sage_helper import _within_sage # type: ignore if _within_sage: - import sage.all # type: ignore + from ..sage_helper import Infinity __all__ = ['distance_r13_lines', 'lower_bound_distance_r13_line_triangle'] @@ -183,7 +183,7 @@ def _safe_sqrt(p): if is_RealIntervalFieldElement(p): RIF = p.parent() - p = p.intersection(RIF(0, sage.all.Infinity)) + p = p.intersection(RIF(0, Infinity)) else: if p < 0: RF = p.parent() @@ -193,7 +193,7 @@ def _safe_sqrt(p): def _safe_log(p): if is_RealIntervalFieldElement(p): RIF = p.parent() - p = p.intersection(RIF(0, sage.all.Infinity)) + p = p.intersection(RIF(0, Infinity)) else: if p <= 0: RF = p.parent() @@ -207,7 +207,7 @@ def _safe_log_non_neg(p): if p == 0: if is_RealIntervalFieldElement(p): RIF = p.parent() - return RIF(-sage.all.Infinity) + return RIF(-Infinity) else: RF = p.parent() return RF(-1e20) @@ -217,7 +217,7 @@ def _safe_log_non_neg(p): def _safe_arccosh(p): if is_RealIntervalFieldElement(p): RIF = p.parent() - p = p.intersection(RIF(1, sage.all.Infinity)) + p = p.intersection(RIF(1, Infinity)) else: if p < 1: RF = p.parent() @@ -233,9 +233,9 @@ def _safe_div(a, b): if is_RealIntervalFieldElement(b): RIF = b.parent() if b == 0: - return RIF(sage.all.Infinity) + return RIF(Infinity) else: - return a / b.intersection(RIF(0, sage.all.Infinity)) + return a / b.intersection(RIF(0, Infinity)) else: if b <= 0: RIF = b.parent() diff --git a/python/math_basics.py b/python/math_basics.py index 5796ee368..bdcdf72f0 100644 --- a/python/math_basics.py +++ b/python/math_basics.py @@ -21,7 +21,8 @@ def is_Interval(x): return is_RealIntervalFieldElement(x) or is_ComplexIntervalFieldElement(x) if _within_sage: - from sage.all import prod, xgcd + from .sage_helper import prod, xgcd + from sage.rings.real_mpfi import RealIntervalFieldElement from sage.rings.complex_interval import ComplexIntervalFieldElement diff --git a/python/number.py b/python/number.py index aaf238fd3..ac665c2ed 100644 --- a/python/number.py +++ b/python/number.py @@ -11,7 +11,7 @@ precision_of_exact_GEN = pari(0).precision() if _within_sage: - from sage.all import RealField, Integer, Rational, ZZ, QQ, RR, CC, SR + from .sage_helper import RealField, Integer, Rational, ZZ, QQ, RR, CC from sage.structure.parent import Parent from sage.structure.unique_representation import UniqueRepresentation from sage.categories.homset import Hom @@ -66,8 +66,13 @@ def __init__(self, precision): self._precision = precision self.register_coercion(MorphismToSPN(ZZ, self, self._precision)) self.register_coercion(MorphismToSPN(QQ, self, self._precision)) - to_SR = Hom(self, SR, Sets())(lambda x: SR(x.sage())) - SR.register_coercion(to_SR) + try: + from sage.symbolic.ring import SR + except ImportError: + pass + else: + to_SR = Hom(self, SR, Sets())(lambda x: SR(x.sage())) + SR.register_coercion(to_SR) def _repr_(self): return "SnapPy Numbers with %s bits precision" % self._precision diff --git a/python/pari.py b/python/pari.py index e83591599..3676fc85b 100644 --- a/python/pari.py +++ b/python/pari.py @@ -17,7 +17,11 @@ from cypari2.pari_instance import (prec_words_to_bits, prec_bits_to_dec, prec_dec_to_bits) - from sage.all import PariError + try: + from sage.all import PariError + except ImportError: + from sage.libs.pari.all import PariError + shut_up = lambda: None speak_up = lambda: None diff --git a/python/sage_helper.py b/python/sage_helper.py index 28517b672..4881c67bb 100644 --- a/python/sage_helper.py +++ b/python/sage_helper.py @@ -9,7 +9,7 @@ """ try: - import sage.all + import sage.structure.sage_object _within_sage = True except ImportError: _within_sage = False @@ -22,11 +22,73 @@ def sage_method(function): function._sage_method = True return function + try: + # Monolithic Sage library + from sage.all import RealField, RealDoubleElement, gcd, xgcd, prod, powerset + from sage.all import MatrixSpace, matrix, vector, ZZ + from sage.all import Integer, Rational, QQ, RR, CC + from sage.all import sqrt + from sage.all import I, Infinity + from sage.all import arccosh + from sage.all import RIF, CIF + from sage.all import (cached_method, real_part, imag_part, round, ceil, floor, log, + CDF, ComplexDoubleField, ComplexField, CyclotomicField, NumberField, PolynomialRing, identity_matrix) + from sage.all import FiniteField as GF + from sage.all import VectorSpace, ChainComplex + from sage.all import ComplexBallField, exp, sin, block_matrix, prime_range, det + from sage.all import LaurentPolynomialRing, AbelianGroup, GroupAlgebra + except ImportError: + # Modularized Sage library + from sage.algebras.group_algebra import GroupAlgebra + from sage.arith.misc import gcd, xgcd + from sage.combinat.subset import powerset + from sage.functions.hyperbolic import arccosh + from sage.functions.log import exp + from sage.functions.other import (real as real_part, + imag as imag_part, + ceil, + floor) + from sage.functions.trig import sin + from sage.groups.abelian_gps.abelian_group import AbelianGroup + from sage.homology.chain_complex import ChainComplex + from sage.matrix.constructor import Matrix as matrix + from sage.matrix.matrix_space import MatrixSpace + from sage.matrix.special import block_matrix, identity_matrix + from sage.misc.cachefunc import cached_method + from sage.misc.functional import det, log, round, sqrt + from sage.misc.misc_c import prod + from sage.modules.free_module import VectorSpace + from sage.modules.free_module_element import free_module_element as vector + from sage.rings.cc import CC + from sage.rings.cif import CIF + from sage.rings.complex_arb import ComplexBallField + from sage.rings.complex_double import CDF, ComplexDoubleField + from sage.rings.complex_mpfr import ComplexField + from sage.rings.fast_arith import prime_range + from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF + from sage.rings.imaginary_unit import I + from sage.rings.infinity import Infinity + from sage.rings.integer import Integer + from sage.rings.integer_ring import ZZ + from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing + from sage.rings.number_field.number_field import CyclotomicField, NumberField + from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing + from sage.rings.rational import Rational + from sage.rings.rational_field import QQ + from sage.rings.real_double import RealDoubleElement + from sage.rings.real_mpfi import RIF + from sage.rings.real_mpfr import RealField, RealNumber, RR + + from sage.rings.complex_interval_field import ComplexIntervalField + from sage.rings.real_mpfi import is_RealIntervalFieldElement, RealIntervalField + from sage.rings.real_mpfr import RealNumber, RealField_class + from sage.structure.sage_object import SageObject + try: # Sage >= 9.3, see https://trac.sagemath.org/ticket/24483 from sage.rings.complex_mpfr import (ComplexField, ComplexField_class, create_ComplexNumber) - except ModuleNotFoundError: + except ImportError: from sage.rings.complex_field import ComplexField, ComplexField_class from sage.rings.complex_number import create_ComplexNumber diff --git a/python/snap/character_varieties.py b/python/snap/character_varieties.py index 35f6c7ab8..e5b2cf47d 100644 --- a/python/snap/character_varieties.py +++ b/python/snap/character_varieties.py @@ -359,7 +359,7 @@ def character_variety_ideal(gens, rels=None): 2 """ presentation = character_variety(gens, rels) - from sage.all import PolynomialRing, QQ + from ..sage_helper import PolynomialRing, QQ R = PolynomialRing(QQ, [repr(v) for v in presentation.gens]) return R.ideal([R(p) for p in presentation.rels]) diff --git a/python/snap/find_field.py b/python/snap/find_field.py index 8421ac3e3..db754cc3f 100644 --- a/python/snap/find_field.py +++ b/python/snap/find_field.py @@ -1,8 +1,9 @@ -from sage.all import (cached_method, real_part, imag_part, round, ceil, floor, log, - ZZ, QQ, CDF, ComplexField, NumberField, PolynomialRing, - matrix, identity_matrix) import itertools +from ..sage_helper import (cached_method, real_part, imag_part, round, ceil, floor, log, + ZZ, QQ, CDF, ComplexField, NumberField, PolynomialRing, + matrix, identity_matrix) + def error(poly, z, a=ZZ(0)): """ diff --git a/python/snap/fundamental_polyhedron.py b/python/snap/fundamental_polyhedron.py index ff26468f0..37b10baed 100644 --- a/python/snap/fundamental_polyhedron.py +++ b/python/snap/fundamental_polyhedron.py @@ -11,7 +11,7 @@ from ..sage_helper import _within_sage if _within_sage: - from sage.all import matrix + from ..sage_helper import matrix else: from .utilities import Matrix2x2 as matrix diff --git a/python/snap/nsagetools.py b/python/snap/nsagetools.py index ea490b0cc..282ec449e 100644 --- a/python/snap/nsagetools.py +++ b/python/snap/nsagetools.py @@ -5,11 +5,9 @@ from ..sage_helper import _within_sage, sage_method if _within_sage: - import sage - from sage.all import (ZZ, vector, matrix, block_matrix, identity_matrix, - gcd, prod, det, MatrixSpace, AbelianGroup, GroupAlgebra, - SageObject, PolynomialRing, LaurentPolynomialRing) - + from ..sage_helper import ZZ, vector, matrix, block_matrix, identity_matrix, gcd, prod, det + from ..sage_helper import MatrixSpace, PolynomialRing, LaurentPolynomialRing + from ..sage_helper import SageObject, AbelianGroup, GroupAlgebra from .polished_reps import polished_holonomy, MatrixRepresentation Id2 = MatrixSpace(ZZ, 2)(1) else: diff --git a/python/snap/peripheral/dual_cellulation.py b/python/snap/peripheral/dual_cellulation.py index 0bcee8762..c43e7a069 100644 --- a/python/snap/peripheral/dual_cellulation.py +++ b/python/snap/peripheral/dual_cellulation.py @@ -6,7 +6,8 @@ from .. import t3mlite as t3m if sage_helper._within_sage: - from sage.all import (ZZ, matrix, vector, ChainComplex, Graph) + from ...sage_helper import ZZ, matrix, vector, ChainComplex + from sage.graphs.graph import Graph class DualCell(): diff --git a/python/snap/peripheral/peripheral.py b/python/snap/peripheral/peripheral.py index 0bc162f7d..1be7f24bb 100644 --- a/python/snap/peripheral/peripheral.py +++ b/python/snap/peripheral/peripheral.py @@ -3,7 +3,7 @@ from . import link, dual_cellulation if sage_helper._within_sage: - from sage.all import matrix, vector, ZZ + from ...sage_helper import matrix, vector, ZZ def peripheral_curve_from_snappy(dual_cell, snappy_data): diff --git a/python/snap/peripheral/surface.py b/python/snap/peripheral/surface.py index 5a5f078fc..7e00a4ca2 100644 --- a/python/snap/peripheral/surface.py +++ b/python/snap/peripheral/surface.py @@ -2,8 +2,8 @@ from ... import sage_helper if sage_helper._within_sage: - from sage.all import (ZZ, matrix, vector, ChainComplex, - cached_method, line, arrow, text) + from ...sage_helper import ZZ, matrix, vector, cached_method, ChainComplex + from sage.plot.all import line, arrow, text else: def cached_method(func): return func diff --git a/python/snap/polished_reps.py b/python/snap/polished_reps.py index 4d720939f..3e8560582 100644 --- a/python/snap/polished_reps.py +++ b/python/snap/polished_reps.py @@ -10,10 +10,10 @@ from .fundamental_polyhedron import * if _within_sage: - import sage - from sage.all import RealField, ComplexField, gcd, prod, powerset - from sage.all import MatrixSpace, matrix, vector, ZZ - Object = sage.structure.sage_object.SageObject + from ..sage_helper import RealField, ComplexField, gcd, prod, powerset + from ..sage_helper import MatrixSpace, matrix, vector, ZZ + from ..sage_helper import SageObject as Object + identity = lambda A: MatrixSpace(A.base_ring(), A.nrows())(1) abelian_group_elt = lambda v: vector(ZZ, v) else: diff --git a/python/snap/slice_obs_HKL.py b/python/snap/slice_obs_HKL.py index ab9ccb0db..884f989ac 100644 --- a/python/snap/slice_obs_HKL.py +++ b/python/snap/slice_obs_HKL.py @@ -45,10 +45,8 @@ from ..sage_helper import _within_sage, sage_method if _within_sage: - from sage.all import (ZZ, PolynomialRing, LaurentPolynomialRing, - GF, CyclotomicField, vector, matrix, - identity_matrix, block_matrix, is_prime, - MatrixSpace, ChainComplex, prime_range) + from ..sage_helper import ZZ, PolynomialRing, vector, matrix, identity_matrix, MatrixSpace, block_matrix, prime_range + from ..sage_helper import LaurentPolynomialRing, GF, CyclotomicField, ChainComplex from .nsagetools import (MapToFreeAbelianization, compute_torsion, fox_derivative_with_involution, diff --git a/python/snap/t3mlite/spun.py b/python/snap/t3mlite/spun.py index bad74f2ec..c5ee33b51 100644 --- a/python/snap/t3mlite/spun.py +++ b/python/snap/t3mlite/spun.py @@ -10,9 +10,7 @@ from ...sage_helper import _within_sage if _within_sage: - from sage.all import gcd - from sage.all import vector as Vector - from sage.all import matrix as Matrix + from ...sage_helper import vector as Vector, matrix as Matrix, gcd else: from snappy.snap.t3mlite.linalg import Vector, Matrix, gcd diff --git a/python/snap/utilities.py b/python/snap/utilities.py index b6ca2b72d..a6bbdfc7e 100644 --- a/python/snap/utilities.py +++ b/python/snap/utilities.py @@ -12,9 +12,8 @@ from ..pari import pari, PariError from .fundamental_polyhedron import Infinity if _within_sage: - from sage.all import matrix as sage_matrix, vector as sage_vector - from sage.rings.real_mpfr import RealField_class - from ..sage_helper import ComplexField_class + from ..sage_helper import matrix as sage_matrix, vector as sage_vector + from ..sage_helper import RealField_class, ComplexField_class def is_field(R): return isinstance(R, (SnapPyNumbers, RealField_class, diff --git a/python/testing.py b/python/testing.py index 2aeaaf7d0..902a7cbe9 100644 --- a/python/testing.py +++ b/python/testing.py @@ -78,8 +78,13 @@ def parse(self, string, name=''): return doctest.DocTestParser.parse(self, string, name) if _within_sage: - import sage.all - globs = {'PSL': sage.all.PSL, 'BraidGroup': sage.all.BraidGroup} + try: + from sage.all import PSL, BraidGroup + except ImportError: + import sage.groups.perm_gps.permgroup_element + from sage.groups.perm_gps.permgroup_named import PSL + from sage.groups.braid import BraidGroup + globs = {'PSL': PSL, 'BraidGroup': BraidGroup} else: globs = {} diff --git a/python/tiling/tile.py b/python/tiling/tile.py index e3861f1ef..a5c70ad9b 100644 --- a/python/tiling/tile.py +++ b/python/tiling/tile.py @@ -10,7 +10,7 @@ from ..sage_helper import _within_sage # type: ignore if _within_sage: - import sage.all # type: ignore + from ..sage_helper import Infinity import heapq @@ -71,7 +71,7 @@ def compute_tiles(*, # Everything is a keyword argument RF = visited_lifted_tetrahedra._base_point[0].parent() if verified: - minus_infinity = RF(-sage.all.Infinity) + minus_infinity = RF(-Infinity) else: minus_infinity = RF(-1e20) diff --git a/python/upper_halfspace/__init__.py b/python/upper_halfspace/__init__.py index f01d7cde2..d5a23277f 100644 --- a/python/upper_halfspace/__init__.py +++ b/python/upper_halfspace/__init__.py @@ -140,7 +140,7 @@ def _o13_matrix_column(A, m, Aadj): fAmj[0][1].imag() ] if _within_sage: - from sage.all import arccosh as _arccosh + from ..sage_helper import arccosh as _arccosh else: def _arccosh(z): return z.arccosh() diff --git a/python/verify/complex_volume/adjust_torsion.py b/python/verify/complex_volume/adjust_torsion.py index a73f763c9..a2aaf625a 100644 --- a/python/verify/complex_volume/adjust_torsion.py +++ b/python/verify/complex_volume/adjust_torsion.py @@ -1,7 +1,6 @@ from ...sage_helper import _within_sage, sage_method if _within_sage: - from sage.all import pi - import sage.all + from sage.symbolic.constants import pi from .extended_bloch import * from ...snap import t3mlite as t3m diff --git a/python/verify/complex_volume/closed.py b/python/verify/complex_volume/closed.py index 336657b29..958cd177b 100644 --- a/python/verify/complex_volume/closed.py +++ b/python/verify/complex_volume/closed.py @@ -6,8 +6,8 @@ from ...snap.t3mlite import simplex if _within_sage: - from sage.all import pi, xgcd - import sage.all + from sage.symbolic.constants import pi + from ...sage_helper import I, xgcd from .. import hyperbolicity @@ -68,8 +68,8 @@ def zero_lifted_holonomy(manifold, m, l, f): # Compute by what multiple of 2 pi i to adjust g, a, b = xgcd(m_fill, l_fill) - m -= p * a * multiple_of_pi * sage.all.I - l -= p * b * multiple_of_pi * sage.all.I + m -= p * a * multiple_of_pi * I + l -= p * b * multiple_of_pi * I # For sanity, double check that we compute it right. p_interval = (m_fill * m + l_fill * l).imag() / multiple_of_pi @@ -165,4 +165,4 @@ def verified_complex_volume_closed_torsion(manifold, bits_prec=None): # I. # Also add multiples of pi^2/2 to try to get the Chern-Simons part # between -pi^2/4 and pi^2/4. - return normalize_by_pi_square_over_two(complex_volume) / sage.all.I + return normalize_by_pi_square_over_two(complex_volume) / I diff --git a/python/verify/complex_volume/cusped.py b/python/verify/complex_volume/cusped.py index 3fc68d0d1..ac497bf15 100644 --- a/python/verify/complex_volume/cusped.py +++ b/python/verify/complex_volume/cusped.py @@ -1,7 +1,7 @@ from ...sage_helper import _within_sage, sage_method if _within_sage: - import sage.all + from ...sage_helper import I from .. import hyperbolicity from ...geometric_structure.cusp_neighborhood.complex_cusp_cross_section import ComplexCuspCrossSection @@ -53,4 +53,4 @@ def verified_complex_volume_cusped_torsion(manifold, bits_prec=None): # I. # Also add multiples of pi^2/2 to try to get the Chern-Simons part # between -pi^2/4 and pi^2/4. - return normalize_by_pi_square_over_two(complex_volume) / sage.all.I + return normalize_by_pi_square_over_two(complex_volume) / I diff --git a/python/verify/complex_volume/extended_bloch.py b/python/verify/complex_volume/extended_bloch.py index 8a2bdf1ee..379a2c643 100644 --- a/python/verify/complex_volume/extended_bloch.py +++ b/python/verify/complex_volume/extended_bloch.py @@ -1,11 +1,8 @@ from ...sage_helper import _within_sage, sage_method if _within_sage: - from sage.all import (ComplexBallField, - RealField, - Integer, exp, pi) - - import sage.all + from sage.symbolic.constants import pi + from ...sage_helper import I, Integer, RealField, ComplexBallField, exp @sage_method @@ -106,8 +103,8 @@ def compute_Neumanns_Rogers_dilog_from_flattening_w0_w1(w0, w1): # Note that the values computed for log(z) and log(1-z) # are not verified to have the imaginary part between -pi and pi. - logZ = w0 - my_pi * p * sage.all.I - logOneMinusZ = - (w1 - my_pi * q * sage.all.I) + logZ = w0 - my_pi * p * I + logOneMinusZ = - (w1 - my_pi * q * I) # Neumann's formula for the complex volume is # @@ -143,7 +140,7 @@ def compute_Neumanns_Rogers_dilog_from_flattening_w0_w1(w0, w1): # Similar considerations apply to (2) used when Re(z) > 1/2. term1 = logZ * logOneMinusZ - term2 = my_pi * sage.all.I * (p * logOneMinusZ + q * logZ) + term2 = my_pi * I * (p * logOneMinusZ + q * logZ) if z.real().center() < 0.5: # Check that we can apply equation (1) diff --git a/python/verify/hyperbolicity.py b/python/verify/hyperbolicity.py index a549220b3..910bef659 100644 --- a/python/verify/hyperbolicity.py +++ b/python/verify/hyperbolicity.py @@ -7,8 +7,8 @@ 'verify_hyperbolicity' ] if _within_sage: - from sage.all import pi - import sage.all + from sage.symbolic.constants import pi + from ..sage_helper import I class FalseTuple(tuple): @@ -103,7 +103,7 @@ def check_logarithmic_gluing_equations_and_positively_oriented_tets( CIF = shape_intervals[0].parent() RIF = CIF.real_field() # 2 pi i in that field - two_pi_i = CIF(2 * pi * sage.all.I) + two_pi_i = CIF(2 * pi * I) # Index of the next gluing equation to check LHS_index = 0 diff --git a/python/verify/interval_tree.py b/python/verify/interval_tree.py index 95ebd7df2..08ae51dd9 100644 --- a/python/verify/interval_tree.py +++ b/python/verify/interval_tree.py @@ -300,7 +300,7 @@ def check_find_result(self, interval): self.brute_force_find(interval))) def check_consistency(self): - from sage.all import Infinity + from ..sage_helper import Infinity if self._root.isRed: raise Exception("Red root") _IntervalTreeTester._recursively_check_consistency( @@ -308,7 +308,7 @@ def check_consistency(self): @staticmethod def _recursively_check_consistency(node, l, r): - from sage.all import Infinity + from ..sage_helper import Infinity if not node: return -Infinity, 0 @@ -370,7 +370,7 @@ def print_tree_recursively(node, depth): @staticmethod def run_test(): - from sage.all import RIF, sin, Infinity + from ..sage_helper import RIF, Infinity, sin intervals = [ RIF(sin(1.2 * i), sin(1.2 * i) + sin(1.43 * i) ** 2) diff --git a/python/verify/krawczyk_shapes_engine.py b/python/verify/krawczyk_shapes_engine.py index 5e16821b3..1313a3db6 100644 --- a/python/verify/krawczyk_shapes_engine.py +++ b/python/verify/krawczyk_shapes_engine.py @@ -4,9 +4,7 @@ from ..sage_helper import _within_sage, sage_method if _within_sage: - from sage.rings.complex_interval_field import ComplexIntervalField - from sage.rings.real_mpfi import RealIntervalField - from sage.all import ComplexDoubleField + from ..sage_helper import ComplexDoubleField, ComplexIntervalField, RealIntervalField from snappy.pari import prec_dec_to_bits __all__ = ['KrawczykShapesEngine'] diff --git a/python/verify/maximal_cusp_area_matrix/cusp_tiling_engine.py b/python/verify/maximal_cusp_area_matrix/cusp_tiling_engine.py index 397cf994f..11312914d 100644 --- a/python/verify/maximal_cusp_area_matrix/cusp_tiling_engine.py +++ b/python/verify/maximal_cusp_area_matrix/cusp_tiling_engine.py @@ -15,8 +15,7 @@ from .cusp_translate_engine import * if _within_sage: - from sage.all import matrix - import sage.all + from ...sage_helper import matrix import heapq diff --git a/python/verify/maximal_cusp_area_matrix/cusp_translate_engine.py b/python/verify/maximal_cusp_area_matrix/cusp_translate_engine.py index cafcdc326..15a390c06 100644 --- a/python/verify/maximal_cusp_area_matrix/cusp_translate_engine.py +++ b/python/verify/maximal_cusp_area_matrix/cusp_translate_engine.py @@ -3,7 +3,7 @@ from ..upper_halfspace.finite_point import * if _within_sage: - from sage.all import vector, matrix + from ...sage_helper import vector, matrix __all__ = ['CuspTranslateEngine'] diff --git a/python/verify/short_slopes.py b/python/verify/short_slopes.py index 4ff6456d7..3ecfd31d9 100644 --- a/python/verify/short_slopes.py +++ b/python/verify/short_slopes.py @@ -5,7 +5,7 @@ import math if _within_sage: - from sage.all import gcd + from ..sage_helper import gcd else: # Python 3 has gcd in math from math import gcd diff --git a/python/verify/upper_halfspace/extended_matrix.py b/python/verify/upper_halfspace/extended_matrix.py index be53cc96e..2997069e9 100644 --- a/python/verify/upper_halfspace/extended_matrix.py +++ b/python/verify/upper_halfspace/extended_matrix.py @@ -1,7 +1,7 @@ from ...sage_helper import _within_sage if _within_sage: - from sage.all import sqrt + from ...sage_helper import sqrt __all__ = ['ExtendedMatrix'] diff --git a/python/verify/upper_halfspace/finite_point.py b/python/verify/upper_halfspace/finite_point.py index ffc26e26b..0920b4c5f 100644 --- a/python/verify/upper_halfspace/finite_point.py +++ b/python/verify/upper_halfspace/finite_point.py @@ -1,9 +1,8 @@ from ...sage_helper import _within_sage if _within_sage: - import sage.all - from sage.all import matrix, sqrt - from sage.rings.real_mpfi import is_RealIntervalFieldElement + import sage + from ...sage_helper import matrix, sqrt, is_RealIntervalFieldElement, Infinity from .extended_matrix import ExtendedMatrix @@ -169,7 +168,7 @@ def cosh_dist(self, other): RIF = r.parent() if _within_sage: if is_RealIntervalFieldElement(r): - return r.intersection(RIF(1,sage.all.Infinity)) + return r.intersection(RIF(1, Infinity)) if r < 1.0: return RIF(1.0) return r diff --git a/python/verify/upper_halfspace/ideal_point.py b/python/verify/upper_halfspace/ideal_point.py index a76c414eb..d04924c8b 100644 --- a/python/verify/upper_halfspace/ideal_point.py +++ b/python/verify/upper_halfspace/ideal_point.py @@ -17,8 +17,8 @@ from ...sage_helper import _within_sage if _within_sage: - import sage.all - from sage.all import matrix + from ...sage_helper import I, matrix, RIF, CIF + from ...sage_helper import Infinity as sage_Infinity from .finite_point import * from .extended_matrix import * @@ -211,7 +211,7 @@ def Euclidean_height_of_hyperbolic_triangle(idealPoints): for idealPoint in idealPoints: if idealPoint != Infinity: RIF = idealPoint.real().parent() - return RIF(sage.all.Infinity) + return RIF(sage_Infinity) raise Exception("What?") @@ -266,7 +266,7 @@ def _transform_points_to_make_first_one_infinity_and_inv_sl_matrix(idealPoints): z = idealPoints[0] CIF = z.parent() gl_matrix = matrix(CIF, [[ 0, 1], [ 1, -z]]) - sl_matrix = CIF(sage.all.I) * gl_matrix + sl_matrix = CIF(I) * gl_matrix inv_sl_matrix = _adjoint2(sl_matrix) # Apply it @@ -398,8 +398,6 @@ class _IdealPointTester(): """ def matrices(self): - from sage.all import RIF, CIF, matrix - return [ matrix.identity(CIF, 2), matrix( @@ -410,8 +408,6 @@ def matrices(self): [CIF(RIF(-0.3), RIF(1.1)), CIF(1)]]) ] def run_tests(self): - from sage.all import RIF, CIF - bias = RIF(1.5) triangle = [ CIF(0), Infinity, CIF(1) ]