From 51b554fd4ee591f18daa44de447e00c037a78fe6 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 19 Oct 2021 21:51:15 -0700 Subject: [PATCH 01/19] sage.misc.functional: Move sqrt here from sage.functions.other --- src/sage/functions/other.py | 154 +----------------------------------- src/sage/misc/functional.py | 154 ++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 152 deletions(-) diff --git a/src/sage/functions/other.py b/src/sage/functions/other.py index bbccf43c386..bb7e5d7d7bd 100644 --- a/src/sage/functions/other.py +++ b/src/sage/functions/other.py @@ -19,7 +19,7 @@ 'gamma_inc_lower', 'psi', 'beta'), deprecation=24411) from sage.symbolic.function import GinacFunction, BuiltinFunction -from sage.symbolic.expression import Expression, register_symbol, symbol_table, I +from sage.symbolic.expression import Expression, register_symbol, symbol_table from sage.symbolic.ring import SR from sage.rings.all import Integer, Rational, RealField, ZZ, ComplexField from sage.misc.latex import latex @@ -35,7 +35,7 @@ from sage.arith.all import binomial as arith_binomial -one_half = SR.one() / SR(2) +from sage.misc.functional import sqrt class Function_abs(GinacFunction): @@ -752,156 +752,6 @@ def _eval_(self, x): frac = Function_frac() -def _do_sqrt(x, prec=None, extend=True, all=False): - r""" - Used internally to compute the square root of x. - - INPUT: - - - ``x`` - a number - - - ``prec`` - None (default) or a positive integer - (bits of precision) If not None, then compute the square root - numerically to prec bits of precision. - - - ``extend`` - bool (default: True); this is a place - holder, and is always ignored since in the symbolic ring everything - has a square root. - - - ``extend`` - bool (default: True); whether to extend - the base ring to find roots. The extend parameter is ignored if - prec is a positive integer. - - - ``all`` - bool (default: False); whether to return - a list of all the square roots of x. - - - EXAMPLES:: - - sage: from sage.functions.other import _do_sqrt - sage: _do_sqrt(3) - sqrt(3) - sage: _do_sqrt(3,prec=10) - 1.7 - sage: _do_sqrt(3,prec=100) - 1.7320508075688772935274463415 - sage: _do_sqrt(3,all=True) - [sqrt(3), -sqrt(3)] - - Note that the extend parameter is ignored in the symbolic ring:: - - sage: _do_sqrt(3,extend=False) - sqrt(3) - """ - if prec: - if x >= 0: - return RealField(prec)(x).sqrt(all=all) - else: - return ComplexField(prec)(x).sqrt(all=all) - if x == -1: - z = I - else: - z = SR(x) ** one_half - - if all: - if z: - return [z, -z] - else: - return [z] - return z - -def sqrt(x, *args, **kwds): - r""" - INPUT: - - - ``x`` - a number - - - ``prec`` - integer (default: None): if None, returns - an exact square root; otherwise returns a numerical square root if - necessary, to the given bits of precision. - - - ``extend`` - bool (default: True); this is a place - holder, and is always ignored or passed to the sqrt function for x, - since in the symbolic ring everything has a square root. - - - ``all`` - bool (default: False); if True, return all - square roots of self, instead of just one. - - EXAMPLES:: - - sage: sqrt(-1) - I - sage: sqrt(2) - sqrt(2) - sage: sqrt(2)^2 - 2 - sage: sqrt(4) - 2 - sage: sqrt(4,all=True) - [2, -2] - sage: sqrt(x^2) - sqrt(x^2) - - For a non-symbolic square root, there are a few options. - The best is to numerically approximate afterward:: - - sage: sqrt(2).n() - 1.41421356237310 - sage: sqrt(2).n(prec=100) - 1.4142135623730950488016887242 - - Or one can input a numerical type. - - sage: sqrt(2.) - 1.41421356237310 - sage: sqrt(2.000000000000000000000000) - 1.41421356237309504880169 - sage: sqrt(4.0) - 2.00000000000000 - - To prevent automatic evaluation, one can use the ``hold`` parameter - after coercing to the symbolic ring:: - - sage: sqrt(SR(4),hold=True) - sqrt(4) - sage: sqrt(4,hold=True) - Traceback (most recent call last): - ... - TypeError: ..._do_sqrt() got an unexpected keyword argument 'hold' - - This illustrates that the bug reported in :trac:`6171` has been fixed:: - - sage: a = 1.1 - sage: a.sqrt(prec=100) # this is supposed to fail - Traceback (most recent call last): - ... - TypeError: ...sqrt() got an unexpected keyword argument 'prec' - sage: sqrt(a, prec=100) - 1.0488088481701515469914535137 - sage: sqrt(4.00, prec=250) - 2.0000000000000000000000000000000000000000000000000000000000000000000000000 - - One can use numpy input as well:: - - sage: import numpy - sage: a = numpy.arange(2,5) - sage: sqrt(a) - array([1.41421356, 1.73205081, 2. ]) - """ - if isinstance(x, float): - return math.sqrt(x) - elif type(x).__module__ == 'numpy': - from numpy import sqrt - return sqrt(x) - try: - return x.sqrt(*args, **kwds) - # The following includes TypeError to catch cases where sqrt - # is called with a "prec" keyword, for example, but the sqrt - # method for x doesn't accept such a keyword. - except (AttributeError, TypeError): - pass - return _do_sqrt(x, *args, **kwds) - # register sqrt in pynac symbol_table for conversion back from other systems register_symbol(sqrt, dict(mathematica='Sqrt')) symbol_table['functions']['sqrt'] = sqrt diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py index 45d74ea749a..88447abb8b8 100644 --- a/src/sage/misc/functional.py +++ b/src/sage/misc/functional.py @@ -1679,6 +1679,160 @@ def squarefree_part(x): return n * F.unit() +def _do_sqrt(x, prec=None, extend=True, all=False): + r""" + Used internally to compute the square root of x. + + INPUT: + + - ``x`` - a number + + - ``prec`` - None (default) or a positive integer + (bits of precision) If not None, then compute the square root + numerically to prec bits of precision. + + - ``extend`` - bool (default: True); this is a place + holder, and is always ignored since in the symbolic ring everything + has a square root. + + - ``extend`` - bool (default: True); whether to extend + the base ring to find roots. The extend parameter is ignored if + prec is a positive integer. + + - ``all`` - bool (default: False); whether to return + a list of all the square roots of x. + + + EXAMPLES:: + + sage: from sage.functions.other import _do_sqrt + sage: _do_sqrt(3) + sqrt(3) + sage: _do_sqrt(3,prec=10) + 1.7 + sage: _do_sqrt(3,prec=100) + 1.7320508075688772935274463415 + sage: _do_sqrt(3,all=True) + [sqrt(3), -sqrt(3)] + + Note that the extend parameter is ignored in the symbolic ring:: + + sage: _do_sqrt(3,extend=False) + sqrt(3) + """ + if prec: + if x >= 0: + return RealField(prec)(x).sqrt(all=all) + else: + return ComplexField(prec)(x).sqrt(all=all) + if x == -1: + from sage.symbolic.expression import I + z = I + else: + from sage.symbolic.ring import SR + z = SR(x).sqrt() + + if all: + if z: + return [z, -z] + else: + return [z] + return z + + +def sqrt(x, *args, **kwds): + r""" + INPUT: + + - ``x`` - a number + + - ``prec`` - integer (default: None): if None, returns + an exact square root; otherwise returns a numerical square root if + necessary, to the given bits of precision. + + - ``extend`` - bool (default: True); this is a place + holder, and is always ignored or passed to the sqrt function for x, + since in the symbolic ring everything has a square root. + + - ``all`` - bool (default: False); if True, return all + square roots of self, instead of just one. + + EXAMPLES:: + + sage: sqrt(-1) + I + sage: sqrt(2) + sqrt(2) + sage: sqrt(2)^2 + 2 + sage: sqrt(4) + 2 + sage: sqrt(4,all=True) + [2, -2] + sage: sqrt(x^2) + sqrt(x^2) + + For a non-symbolic square root, there are a few options. + The best is to numerically approximate afterward:: + + sage: sqrt(2).n() + 1.41421356237310 + sage: sqrt(2).n(prec=100) + 1.4142135623730950488016887242 + + Or one can input a numerical type. + + sage: sqrt(2.) + 1.41421356237310 + sage: sqrt(2.000000000000000000000000) + 1.41421356237309504880169 + sage: sqrt(4.0) + 2.00000000000000 + + To prevent automatic evaluation, one can use the ``hold`` parameter + after coercing to the symbolic ring:: + + sage: sqrt(SR(4),hold=True) + sqrt(4) + sage: sqrt(4,hold=True) + Traceback (most recent call last): + ... + TypeError: ..._do_sqrt() got an unexpected keyword argument 'hold' + + This illustrates that the bug reported in :trac:`6171` has been fixed:: + + sage: a = 1.1 + sage: a.sqrt(prec=100) # this is supposed to fail + Traceback (most recent call last): + ... + TypeError: ...sqrt() got an unexpected keyword argument 'prec' + sage: sqrt(a, prec=100) + 1.0488088481701515469914535137 + sage: sqrt(4.00, prec=250) + 2.0000000000000000000000000000000000000000000000000000000000000000000000000 + + One can use numpy input as well:: + + sage: import numpy + sage: a = numpy.arange(2,5) + sage: sqrt(a) + array([1.41421356, 1.73205081, 2. ]) + """ + if isinstance(x, float): + return math.sqrt(x) + elif type(x).__module__ == 'numpy': + from numpy import sqrt + return sqrt(x) + try: + return x.sqrt(*args, **kwds) + # The following includes TypeError to catch cases where sqrt + # is called with a "prec" keyword, for example, but the sqrt + # method for x doesn't accept such a keyword. + except (AttributeError, TypeError): + pass + return _do_sqrt(x, *args, **kwds) + + def transpose(x): """ Return the transpose of ``x``. From 71165ea7fe3d608a770eba00d6831d2b8d189f1f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 19 Oct 2021 21:54:38 -0700 Subject: [PATCH 02/19] git grep -l 'functions.*import.*sqrt' | xargs sed -i.bak 's/from sage[.]functions[.].* import sqrt *$/from sage.misc.functional import sqrt/' --- src/sage/coding/linear_code.py | 2 +- src/sage/combinat/binary_recurrence_sequences.py | 2 +- src/sage/combinat/parallelogram_polyomino.py | 2 +- src/sage/combinat/root_system/plot.py | 2 +- src/sage/combinat/symmetric_group_representations.py | 2 +- .../arithmetic_dynamics/endPN_automorphism_group.py | 2 +- src/sage/dynamics/arithmetic_dynamics/projective_ds.py | 2 +- src/sage/dynamics/arithmetic_dynamics/wehlerK3.py | 2 +- src/sage/functions/bessel.py | 2 +- src/sage/functions/orthogonal_polys.py | 2 +- .../geometry/riemannian_manifolds/parametrized_surface3d.py | 2 +- src/sage/graphs/generators/distance_regular.pyx | 2 +- src/sage/graphs/generators/smallgraphs.py | 2 +- src/sage/graphs/generic_graph.py | 2 +- src/sage/graphs/graph_plot.py | 2 +- src/sage/interacts/library.py | 2 +- src/sage/knots/knotinfo.py | 2 +- src/sage/manifolds/catalog.py | 2 +- src/sage/manifolds/differentiable/examples/euclidean.py | 2 +- src/sage/manifolds/differentiable/examples/sphere.py | 2 +- src/sage/matrix/matrix2.pyx | 4 ++-- src/sage/matrix/special.py | 2 +- src/sage/modular/modform_hecketriangle/element.py | 2 +- src/sage/modules/with_basis/representation.py | 2 +- src/sage/plot/plot3d/revolution_plot3d.py | 2 +- src/sage/plot/plot_field.py | 2 +- src/sage/plot/streamline_plot.py | 2 +- src/sage/probability/random_variable.py | 2 +- src/sage/quadratic_forms/quadratic_form__siegel_product.py | 2 +- .../asymptotics_multivariate_generating_functions.py | 2 +- src/sage/rings/number_field/number_field_element.pyx | 2 +- src/sage/rings/polynomial/polynomial_element.pyx | 2 +- src/sage/rings/rational.pyx | 2 +- src/sage/schemes/elliptic_curves/ell_modular_symbols.py | 2 +- src/sage/stats/basic_stats.py | 2 +- src/sage/symbolic/expression_conversions.py | 6 +++--- 36 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/sage/coding/linear_code.py b/src/sage/coding/linear_code.py index eb50986d29e..643e7239460 100644 --- a/src/sage/coding/linear_code.py +++ b/src/sage/coding/linear_code.py @@ -837,7 +837,7 @@ def chinen_polynomial(self): - Chinen, K. "An abundance of invariant polynomials satisfying the Riemann hypothesis", April 2007 preprint. """ - from sage.functions.all import sqrt + from sage.misc.functional import sqrt C = self n = C.length() RT = PolynomialRing(QQ,2,"Ts") diff --git a/src/sage/combinat/binary_recurrence_sequences.py b/src/sage/combinat/binary_recurrence_sequences.py index b9ec447170a..9bd217b5d5e 100644 --- a/src/sage/combinat/binary_recurrence_sequences.py +++ b/src/sage/combinat/binary_recurrence_sequences.py @@ -67,7 +67,7 @@ from sage.rings.integer import Integer from sage.arith.all import lcm, next_prime, is_prime, next_prime_power, legendre_symbol from sage.functions.log import log -from sage.functions.other import sqrt +from sage.misc.functional import sqrt class BinaryRecurrenceSequence(SageObject): diff --git a/src/sage/combinat/parallelogram_polyomino.py b/src/sage/combinat/parallelogram_polyomino.py index 48a8de037f8..9dbdf47baf1 100644 --- a/src/sage/combinat/parallelogram_polyomino.py +++ b/src/sage/combinat/parallelogram_polyomino.py @@ -39,7 +39,7 @@ from sage.combinat.combinat import catalan_number from sage.combinat.combinatorial_map import combinatorial_map from sage.functions.trig import cos, sin -from sage.functions.other import sqrt +from sage.misc.functional import sqrt from sage.plot.graphics import Graphics from sage.plot.line import line diff --git a/src/sage/combinat/root_system/plot.py b/src/sage/combinat/root_system/plot.py index 36da0e98384..41371737f7a 100644 --- a/src/sage/combinat/root_system/plot.py +++ b/src/sage/combinat/root_system/plot.py @@ -1574,7 +1574,7 @@ def barycentric_projection_matrix(n, angle=0): """ from sage.matrix.constructor import matrix - from sage.functions.other import sqrt + from sage.misc.functional import sqrt n = ZZ(n) if n == 0: return matrix(QQ, 0, 1) diff --git a/src/sage/combinat/symmetric_group_representations.py b/src/sage/combinat/symmetric_group_representations.py index 169d0f862ef..363e1cf78a5 100644 --- a/src/sage/combinat/symmetric_group_representations.py +++ b/src/sage/combinat/symmetric_group_representations.py @@ -29,7 +29,7 @@ # **************************************************************************** from sage.symbolic.ring import SR -from sage.functions.all import sqrt +from sage.misc.functional import sqrt from sage.combinat.partition import Partition, Partitions from sage.combinat.permutation import Permutation, Permutations, from_cycles from sage.combinat.tableau import StandardTableaux, Tableau diff --git a/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py b/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py index e5ef59acf59..14ae3029a87 100644 --- a/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py +++ b/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py @@ -23,7 +23,7 @@ from copy import copy, deepcopy from sage.combinat.subset import Subsets -from sage.functions.all import sqrt +from sage.misc.functional import sqrt from itertools import permutations, combinations, product from sage.matrix.constructor import matrix from sage.structure.element import is_Matrix diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 27f9c39b583..32a3a77dadd 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -59,7 +59,7 @@ class initialization directly. from sage.categories.number_fields import NumberFields from sage.categories.homset import End from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem -from sage.functions.all import sqrt +from sage.misc.functional import sqrt from sage.functions.other import ceil from sage.libs.pari.all import PariError from sage.matrix.constructor import matrix, identity_matrix diff --git a/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py b/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py index a385b8a54b9..c8ad02059fe 100644 --- a/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py +++ b/src/sage/dynamics/arithmetic_dynamics/wehlerK3.py @@ -29,7 +29,7 @@ from sage.calculus.functions import jacobian from sage.categories.fields import Fields from sage.categories.number_fields import NumberFields -from sage.functions.all import sqrt +from sage.misc.functional import sqrt from sage.misc.cachefunc import cached_method from sage.misc.mrange import xmrange from sage.rings.all import CommutativeRing diff --git a/src/sage/functions/bessel.py b/src/sage/functions/bessel.py index 3ba9ece2359..b51b0b93d02 100644 --- a/src/sage/functions/bessel.py +++ b/src/sage/functions/bessel.py @@ -210,7 +210,7 @@ # https://www.gnu.org/licenses/ # **************************************************************************** -from sage.functions.other import sqrt +from sage.misc.functional import sqrt from sage.functions.log import exp from sage.functions.hyperbolic import sinh, cosh from sage.functions.trig import sin, cos diff --git a/src/sage/functions/orthogonal_polys.py b/src/sage/functions/orthogonal_polys.py index 4c6650f5311..d9cec09210d 100644 --- a/src/sage/functions/orthogonal_polys.py +++ b/src/sage/functions/orthogonal_polys.py @@ -1824,7 +1824,7 @@ def eval_recursive(self, n, m, x, **kwds): sage: gen_legendre_Q(2,2,x).subs(x=2).expand() 9/2*I*pi - 9/2*log(3) + 14/3 """ - from sage.functions.all import sqrt + from sage.misc.functional import sqrt if m == n + 1 or n == 0: if m.mod(2).is_zero(): denom = (1 - x**2)**(m/2) diff --git a/src/sage/geometry/riemannian_manifolds/parametrized_surface3d.py b/src/sage/geometry/riemannian_manifolds/parametrized_surface3d.py index ce3e306d277..10ea1e48e2d 100644 --- a/src/sage/geometry/riemannian_manifolds/parametrized_surface3d.py +++ b/src/sage/geometry/riemannian_manifolds/parametrized_surface3d.py @@ -21,7 +21,7 @@ from sage.modules.free_module_element import vector from sage.matrix.constructor import matrix from sage.calculus.functional import diff -from sage.functions.other import sqrt +from sage.misc.functional import sqrt from sage.misc.cachefunc import cached_method from sage.symbolic.ring import SR from sage.symbolic.constants import pi diff --git a/src/sage/graphs/generators/distance_regular.pyx b/src/sage/graphs/generators/distance_regular.pyx index 38c356d8863..55eee4d0a03 100644 --- a/src/sage/graphs/generators/distance_regular.pyx +++ b/src/sage/graphs/generators/distance_regular.pyx @@ -2100,7 +2100,7 @@ def graph_with_classical_parameters(int d, int b, alpha_in, beta_in, int gamma): """ from sage.rings.rational import Rational from sage.functions.log import log - from sage.functions.other import sqrt + from sage.misc.functional import sqrt from sage.graphs.generators.families import JohnsonGraph, HammingGraph from sage.graphs.generators.classical_geometries import \ UnitaryDualPolarGraph, OrthogonalDualPolarGraph, SymplecticDualPolarGraph diff --git a/src/sage/graphs/generators/smallgraphs.py b/src/sage/graphs/generators/smallgraphs.py index a7ddfa7c1d9..072812c75c4 100644 --- a/src/sage/graphs/generators/smallgraphs.py +++ b/src/sage/graphs/generators/smallgraphs.py @@ -18,7 +18,7 @@ # import from Sage library from sage.graphs.graph import Graph from sage.rings.rational_field import QQ -from sage.functions.other import sqrt +from sage.misc.functional import sqrt from math import sin, cos, pi diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index d0850f13357..33f06c06dda 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -2415,7 +2415,7 @@ def kirchhoff_matrix(self, weighted=None, indegree=True, normalized=False, signl [-4 -3 -1 8] """ from sage.matrix.constructor import diagonal_matrix - from sage.functions.all import sqrt + from sage.misc.functional import sqrt if weighted is None: weighted = self._weighted diff --git a/src/sage/graphs/graph_plot.py b/src/sage/graphs/graph_plot.py index 23ffeb016f0..de7086ed71f 100644 --- a/src/sage/graphs/graph_plot.py +++ b/src/sage/graphs/graph_plot.py @@ -799,7 +799,7 @@ def set_edges(self, **edge_options): dist = self._options['dist'] * 2 min_loop_size = self._options['loop_size'] max_dist = self._options['max_dist'] - from sage.functions.all import sqrt + from sage.misc.functional import sqrt for a, b in tmp: if a == b: # Multiple loops need varying loop radius starting at diff --git a/src/sage/interacts/library.py b/src/sage/interacts/library.py index 63b6ff674a4..153ba021b8f 100644 --- a/src/sage/interacts/library.py +++ b/src/sage/interacts/library.py @@ -42,7 +42,7 @@ from sage.calculus.integration import numerical_integral as integral_numerical from sage.ext.fast_callable import fast_callable from sage.functions.log import exp -from sage.functions.other import sqrt +from sage.misc.functional import sqrt from sage.functions.trig import (acos, cos, sin, tan) from sage.misc.decorators import sage_wraps from sage.misc.functional import N diff --git a/src/sage/knots/knotinfo.py b/src/sage/knots/knotinfo.py index 54b7812a3b0..d74b433c439 100644 --- a/src/sage/knots/knotinfo.py +++ b/src/sage/knots/knotinfo.py @@ -1499,7 +1499,7 @@ def jones_polynomial(self, variab=None, skein_normalization=False, puiseux=False elif puiseux: lc = {'x': t**(1/2)} elif use_sqrt: - from sage.functions.other import sqrt + from sage.misc.functional import sqrt lc = {'x': sqrt(t)} else: lc = {'x': t} diff --git a/src/sage/manifolds/catalog.py b/src/sage/manifolds/catalog.py index a73a93382a8..a0a04f90bce 100644 --- a/src/sage/manifolds/catalog.py +++ b/src/sage/manifolds/catalog.py @@ -159,7 +159,7 @@ def Kerr(m=1, a=0, coordinates="BL", names=None): sage: K.default_chart().coord_range() t: (-oo, +oo); r: (0, +oo); th: (0, pi); ph: [-pi, pi] (periodic) """ - from sage.functions.other import sqrt + from sage.misc.functional import sqrt from sage.functions.trig import cos, sin from sage.manifolds.manifold import Manifold M = Manifold(4, 'M', structure="Lorentzian") diff --git a/src/sage/manifolds/differentiable/examples/euclidean.py b/src/sage/manifolds/differentiable/examples/euclidean.py index b0659787b0e..e85d5c1d2c0 100644 --- a/src/sage/manifolds/differentiable/examples/euclidean.py +++ b/src/sage/manifolds/differentiable/examples/euclidean.py @@ -410,7 +410,7 @@ #***************************************************************************** from sage.functions.trig import cos, sin, atan2 -from sage.functions.other import sqrt +from sage.misc.functional import sqrt from sage.misc.latex import latex from sage.rings.real_mpfr import RR from sage.categories.manifolds import Manifolds diff --git a/src/sage/manifolds/differentiable/examples/sphere.py b/src/sage/manifolds/differentiable/examples/sphere.py index 9dbdf3bdd40..3b9df0f6c79 100644 --- a/src/sage/manifolds/differentiable/examples/sphere.py +++ b/src/sage/manifolds/differentiable/examples/sphere.py @@ -1018,7 +1018,7 @@ def _transition_spher_stereo(self): # transition: stereoN to spher... from sage.functions.trig import acos, atan2 - from sage.functions.special import sqrt + from sage.misc.functional import sqrt # get ambient coordinates and shift to coordinate origin: x = self._shift_coords(imm.expr(stereoN, cart), s='-') coordfunc = [atan2(x[1],x[0])] diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 75d8dc56424..6a1776da9ab 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -10208,7 +10208,7 @@ cdef class Matrix(Matrix1): """ from sage.modules.free_module_element import zero_vector from sage.matrix.constructor import zero_matrix, matrix - from sage.functions.other import sqrt + from sage.misc.functional import sqrt if full: QR = self.fetch('QR_factors') @@ -14666,7 +14666,7 @@ cdef class Matrix(Matrix1): True """ from sage.matrix.special import diagonal_matrix - from sage.functions.other import sqrt + from sage.misc.functional import sqrt if check_positivity and not self.is_positive_definite(): return False diff --git a/src/sage/matrix/special.py b/src/sage/matrix/special.py index bcb0b0293af..2f9b5f285a9 100644 --- a/src/sage/matrix/special.py +++ b/src/sage/matrix/special.py @@ -3402,7 +3402,7 @@ def ith_to_zero_rotation_matrix(v, i, ring=None): a, b = v[j], v[i] if b == 0: return identity_matrix(dim, sparse=True) - from sage.functions.all import sqrt + from sage.misc.functional import sqrt norm = sqrt(a * a + b * b) aa = a / norm bb = b / norm diff --git a/src/sage/modular/modform_hecketriangle/element.py b/src/sage/modular/modform_hecketriangle/element.py index 4f8114f1125..4959652a921 100644 --- a/src/sage/modular/modform_hecketriangle/element.py +++ b/src/sage/modular/modform_hecketriangle/element.py @@ -286,7 +286,7 @@ def lseries(self, num_prec=None, max_imaginary_part=0, max_asymp_coeffs=40): """ from sage.rings.integer_ring import ZZ from sage.symbolic.all import pi - from sage.functions.other import sqrt + from sage.misc.functional import sqrt from sage.lfunctions.dokchitser import Dokchitser if (not (self.is_modular() and self.is_holomorphic()) or self.weight() == 0): diff --git a/src/sage/modules/with_basis/representation.py b/src/sage/modules/with_basis/representation.py index e6f97d219a5..496dd5b0e40 100644 --- a/src/sage/modules/with_basis/representation.py +++ b/src/sage/modules/with_basis/representation.py @@ -349,7 +349,7 @@ def _test_representation(self, **options): sage: R = Representation(G, M, on_basis, side="right") sage: R._test_representation(max_runs=500) """ - from sage.functions.other import sqrt + from sage.misc.functional import sqrt tester = self._tester(**options) S = tester.some_elements() L = [] diff --git a/src/sage/plot/plot3d/revolution_plot3d.py b/src/sage/plot/plot3d/revolution_plot3d.py index 50af10cd9a4..ccf18787f48 100644 --- a/src/sage/plot/plot3d/revolution_plot3d.py +++ b/src/sage/plot/plot3d/revolution_plot3d.py @@ -211,7 +211,7 @@ def cf(u, phi): return float(2 * u / pi) % 1 """ from sage.symbolic.ring import SR from sage.symbolic.constants import pi - from sage.functions.other import sqrt + from sage.misc.functional import sqrt from sage.functions.trig import sin from sage.functions.trig import cos from sage.functions.trig import atan2 diff --git a/src/sage/plot/plot_field.py b/src/sage/plot/plot_field.py index 04a60dddcda..b57af986b59 100644 --- a/src/sage/plot/plot_field.py +++ b/src/sage/plot/plot_field.py @@ -348,7 +348,7 @@ def plot_slope_field(f, xrange, yrange, **kwds): 'pivot': 'middle'} slope_options.update(kwds) - from sage.functions.all import sqrt + from sage.misc.functional import sqrt from sage.misc.sageinspect import is_function_or_cython_function if is_function_or_cython_function(f): norm_inverse = lambda x,y: 1/sqrt(f(x, y)**2+1) diff --git a/src/sage/plot/streamline_plot.py b/src/sage/plot/streamline_plot.py index c5d992c957a..2849669f18d 100644 --- a/src/sage/plot/streamline_plot.py +++ b/src/sage/plot/streamline_plot.py @@ -271,7 +271,7 @@ def streamline_plot(f_g, xrange, yrange, **options): if isinstance(f_g, (list, tuple)): (f,g) = f_g else: - from sage.functions.all import sqrt + from sage.misc.functional import sqrt from sage.misc.sageinspect import is_function_or_cython_function if is_function_or_cython_function(f_g): f = lambda x,y: 1 / sqrt(f_g(x, y)**2 + 1) diff --git a/src/sage/probability/random_variable.py b/src/sage/probability/random_variable.py index 47d108996f0..44501d5e2e2 100644 --- a/src/sage/probability/random_variable.py +++ b/src/sage/probability/random_variable.py @@ -18,7 +18,7 @@ import sage.rings.abc from sage.structure.parent import Parent from sage.functions.log import log -from sage.functions.all import sqrt +from sage.misc.functional import sqrt from sage.rings.rational_field import is_RationalField from sage.sets.set import Set from pprint import pformat diff --git a/src/sage/quadratic_forms/quadratic_form__siegel_product.py b/src/sage/quadratic_forms/quadratic_form__siegel_product.py index fb2e72a0f4a..eb2bff7f6cc 100644 --- a/src/sage/quadratic_forms/quadratic_form__siegel_product.py +++ b/src/sage/quadratic_forms/quadratic_form__siegel_product.py @@ -13,7 +13,7 @@ from sage.rings.integer_ring import ZZ from sage.rings.rational_field import QQ from sage.arith.all import kronecker_symbol, bernoulli, prime_divisors, fundamental_discriminant -from sage.functions.all import sqrt +from sage.misc.functional import sqrt from sage.quadratic_forms.special_values import QuadraticBernoulliNumber diff --git a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py index 06301c7633c..8a335d4f852 100644 --- a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py +++ b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py @@ -4163,7 +4163,7 @@ def diff_op_simple(A, B, AB_derivs, x, v, a, N): ((1, 1), 1/4*2^(2/3)*(B(x)*diff(A(x), x, x, x, x) + 4*diff(A(x), x, x, x)*diff(B(x), x) + 6*diff(A(x), x, x)*diff(B(x), x, x) + 4*diff(A(x), x)*diff(B(x), x, x, x) + A(x)*diff(B(x), x, x, x, x)))] """ - from sage.functions.other import sqrt + from sage.misc.functional import sqrt I = sqrt(-ZZ.one()) DD = {} diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx index bba2fc46afc..c1af4f13b22 100644 --- a/src/sage/rings/number_field/number_field_element.pyx +++ b/src/sage/rings/number_field/number_field_element.pyx @@ -2258,7 +2258,7 @@ cdef class NumberFieldElement(FieldElement): if extend and not roots: try: # This is what integers, rationals do... - from sage.functions.other import sqrt + from sage.misc.functional import sqrt from sage.symbolic.ring import SR root = sqrt(SR(self)) roots = [[root, 1], [-root, 1]] diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 056c39152f0..ba116954fc5 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -7935,7 +7935,7 @@ cdef class Polynomial(CommutativeAlgebraElement): from sage.symbolic.ring import SR if L is SR: if self.degree() == 2: - from sage.functions.other import sqrt + from sage.misc.functional import sqrt from sage.symbolic.expression import I coeffs = self.list() D = coeffs[1]*coeffs[1] - 4*coeffs[0]*coeffs[2] diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx index 6e02cf4387d..e6e7a9ff1dc 100644 --- a/src/sage/rings/rational.pyx +++ b/src/sage/rings/rational.pyx @@ -3263,7 +3263,7 @@ cdef class Rational(sage.structure.element.FieldElement): numer = self.numer() rat_part = Rational((numer-2).multifactorial(2)) >> ((numer-1)//2) from sage.symbolic.constants import pi - from sage.functions.all import sqrt + from sage.misc.functional import sqrt return sqrt(pi) * rat_part else: from sage.symbolic.ring import SR diff --git a/src/sage/schemes/elliptic_curves/ell_modular_symbols.py b/src/sage/schemes/elliptic_curves/ell_modular_symbols.py index 30a61e1635c..cb018a51eeb 100644 --- a/src/sage/schemes/elliptic_curves/ell_modular_symbols.py +++ b/src/sage/schemes/elliptic_curves/ell_modular_symbols.py @@ -608,7 +608,7 @@ def __lalg__(self, D): sage: m.__lalg__(3) 5/2 """ - from sage.functions.all import sqrt + from sage.misc.functional import sqrt # the computation of the L-value could take a lot of time, # but then the conductor is so large # that the computation of modular symbols for E took even longer diff --git a/src/sage/stats/basic_stats.py b/src/sage/stats/basic_stats.py index b793d02f493..232b56f1480 100644 --- a/src/sage/stats/basic_stats.py +++ b/src/sage/stats/basic_stats.py @@ -41,7 +41,7 @@ from sage.rings.integer_ring import ZZ from sage.symbolic.constants import NaN -from sage.functions.other import sqrt +from sage.misc.functional import sqrt from sage.misc.superseded import deprecation diff --git a/src/sage/symbolic/expression_conversions.py b/src/sage/symbolic/expression_conversions.py index 98d2820a361..d12c5969e72 100644 --- a/src/sage/symbolic/expression_conversions.py +++ b/src/sage/symbolic/expression_conversions.py @@ -1782,10 +1782,10 @@ def arithmetic(self, ex, operator): if exponent == -1: return self.etb.call(_operator.truediv, 1, operands[0]) elif exponent == 0.5: - from sage.functions.all import sqrt + from sage.misc.functional import sqrt return self.etb.call(sqrt, operands[0]) elif exponent == -0.5: - from sage.functions.all import sqrt + from sage.misc.functional import sqrt return self.etb.call(_operator.truediv, 1, self.etb.call(sqrt, operands[0])) elif operator is _operator.neg: return self.etb.call(operator, operands[0]) @@ -1949,7 +1949,7 @@ def arithmetic(self, ex, operator): base, expt = operands if expt == Rational(((1,2))): - from sage.functions.all import sqrt + from sage.misc.functional import sqrt return sqrt(self(base)) try: expt = Integer(expt) From 12145412d0afc137089d163e6c4698eb1bfa6193 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 19 Oct 2021 21:55:50 -0700 Subject: [PATCH 03/19] git grep -l 'functions.*import.*sqrt' | xargs sed -i.bak 's/from sage[.]functions[.].* import _do_sqrt *$/from sage.misc.functional import _do_sqrt/' --- src/sage/misc/functional.py | 2 +- src/sage/rings/integer.pyx | 4 ++-- src/sage/rings/rational.pyx | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py index 88447abb8b8..ec701dade01 100644 --- a/src/sage/misc/functional.py +++ b/src/sage/misc/functional.py @@ -1705,7 +1705,7 @@ def _do_sqrt(x, prec=None, extend=True, all=False): EXAMPLES:: - sage: from sage.functions.other import _do_sqrt + sage: from sage.misc.functional import _do_sqrt sage: _do_sqrt(3) sqrt(3) sage: _do_sqrt(3,prec=10) diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 56de0fc858a..7e2fd3d6f19 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -6203,7 +6203,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): [] """ if prec is not None: - from sage.functions.other import _do_sqrt + from sage.misc.functional import _do_sqrt return _do_sqrt(self, prec=prec, all=all) if mpz_sgn(self.value) == 0: @@ -6225,7 +6225,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): if not is_square: if extend: - from sage.functions.other import _do_sqrt + from sage.misc.functional import _do_sqrt return _do_sqrt(self, all=all) if all: return [] diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx index e6e7a9ff1dc..d4a6b69e361 100644 --- a/src/sage/rings/rational.pyx +++ b/src/sage/rings/rational.pyx @@ -1943,7 +1943,7 @@ cdef class Rational(sage.structure.element.FieldElement): if mpq_sgn(self.value) < 0: if not extend: raise ValueError("square root of negative number not rational") - from sage.functions.other import _do_sqrt + from sage.misc.functional import _do_sqrt return _do_sqrt(self, prec=prec, all=all) cdef Rational z = Rational.__new__(Rational) @@ -1965,11 +1965,11 @@ cdef class Rational(sage.structure.element.FieldElement): if non_square: if not extend: raise ValueError("square root of %s not a rational number" % self) - from sage.functions.other import _do_sqrt + from sage.misc.functional import _do_sqrt return _do_sqrt(self, prec=prec, all=all) if prec: - from sage.functions.other import _do_sqrt + from sage.misc.functional import _do_sqrt return _do_sqrt(self, prec=prec, all=all) if all: From 4a752e0c2c5b9ee190fa3335d8ed873243163cdf Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 19 Oct 2021 22:03:00 -0700 Subject: [PATCH 04/19] git grep -l 'functions.*import.*sqrt' | xargs sed -E -i.bak $'s/^( *)from (sage[.]functions[.].* import .*)(, *sqrt|sqrt, *)(.*)/\1from \2\4\\n\1from sage.misc.functional import sqrt/' --- src/sage/coding/code_bounds.py | 3 ++- src/sage/coding/guruswami_sudan/gs_decoder.py | 3 ++- src/sage/coding/guruswami_sudan/utils.py | 3 ++- src/sage/combinat/posets/poset_examples.py | 3 ++- src/sage/combinat/words/word_generators.py | 3 ++- src/sage/crypto/lwe.py | 3 ++- src/sage/functions/error.py | 3 ++- src/sage/functions/special.py | 3 ++- src/sage/geometry/hyperbolic_space/hyperbolic_coercion.py | 3 ++- src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py | 3 ++- src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py | 3 ++- src/sage/geometry/hyperbolic_space/hyperbolic_model.py | 3 ++- src/sage/geometry/polyhedron/base.py | 3 ++- .../groups/additive_abelian/additive_abelian_wrapper.py | 3 ++- src/sage/interfaces/tides.py | 3 ++- src/sage/manifolds/utilities.py | 3 ++- src/sage/quadratic_forms/quadratic_form__theta.py | 3 ++- .../asymptotics_multivariate_generating_functions.py | 6 ++++-- src/sage/rings/invariants/reconstruction.py | 3 ++- 19 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/sage/coding/code_bounds.py b/src/sage/coding/code_bounds.py index 38244287ec5..9f5640ca1f4 100644 --- a/src/sage/coding/code_bounds.py +++ b/src/sage/coding/code_bounds.py @@ -177,7 +177,8 @@ from sage.rings.all import QQ, RR, ZZ, RDF from sage.arith.misc import is_prime_power from sage.arith.all import binomial -from sage.functions.all import log, sqrt +from sage.functions.all import log +from sage.misc.functional import sqrt from .delsarte_bounds import (delsarte_bound_hamming_space, delsarte_bound_additive_hamming_space) diff --git a/src/sage/coding/guruswami_sudan/gs_decoder.py b/src/sage/coding/guruswami_sudan/gs_decoder.py index 1a22f1e59fe..455accbbe00 100644 --- a/src/sage/coding/guruswami_sudan/gs_decoder.py +++ b/src/sage/coding/guruswami_sudan/gs_decoder.py @@ -31,7 +31,8 @@ from sage.coding.guruswami_sudan.utils import (johnson_radius, gilt, solve_degree2_to_integer_range) -from sage.functions.other import floor, sqrt +from sage.functions.other import floor +from sage.misc.functional import sqrt def n_k_params(C, n_k): r""" diff --git a/src/sage/coding/guruswami_sudan/utils.py b/src/sage/coding/guruswami_sudan/utils.py index e1b88879605..d53637d933f 100644 --- a/src/sage/coding/guruswami_sudan/utils.py +++ b/src/sage/coding/guruswami_sudan/utils.py @@ -19,7 +19,8 @@ #***************************************************************************** -from sage.functions.other import floor, sqrt +from sage.functions.other import floor +from sage.misc.functional import sqrt from sage.rings.integer_ring import ZZ from sage.rings.integer import Integer diff --git a/src/sage/combinat/posets/poset_examples.py b/src/sage/combinat/posets/poset_examples.py index 962f354c236..c94a00a29db 100644 --- a/src/sage/combinat/posets/poset_examples.py +++ b/src/sage/combinat/posets/poset_examples.py @@ -1924,7 +1924,8 @@ def _random_lattice(n, p): meet for `e, m` for all `m \in M`. We do that by keeping track of meet matrix and list of maximal elements. """ - from sage.functions.other import floor, sqrt + from sage.functions.other import floor + from sage.misc.functional import sqrt from sage.misc.prandom import random n = n-1 diff --git a/src/sage/combinat/words/word_generators.py b/src/sage/combinat/words/word_generators.py index 9b5c7fe08fb..ec0d44e5f8c 100644 --- a/src/sage/combinat/words/word_generators.py +++ b/src/sage/combinat/words/word_generators.py @@ -574,7 +574,8 @@ def FibonacciWord(self, alphabet=(0, 1), construction_method="recursive"): return w elif construction_method == "function": - from sage.functions.other import sqrt, floor + from sage.functions.other import floor + from sage.misc.functional import sqrt phi = (1 + sqrt(5))/2 # the golden ratio f = lambda n:a if floor((n+2)*phi) - floor((n+1)*phi) == 2 else b return W(f) diff --git a/src/sage/crypto/lwe.py b/src/sage/crypto/lwe.py index b74c2213dd3..8224caf5da7 100644 --- a/src/sage/crypto/lwe.py +++ b/src/sage/crypto/lwe.py @@ -92,7 +92,8 @@ """ from sage.functions.log import log -from sage.functions.other import sqrt, floor, ceil +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.prandom import randint diff --git a/src/sage/functions/error.py b/src/sage/functions/error.py index f74395aaa04..f48d04f1c41 100644 --- a/src/sage/functions/error.py +++ b/src/sage/functions/error.py @@ -44,7 +44,8 @@ from sage.symbolic.function import BuiltinFunction from sage.libs.mpmath import utils as mpmath_utils from sage.symbolic.expression import Expression -from sage.functions.all import sqrt, exp +from sage.functions.all import exp +from sage.misc.functional import sqrt from sage.symbolic.constants import pi from sage.rings.rational import Rational from sage.rings.infinity import unsigned_infinity diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py index 97070d07d9e..e507844219e 100644 --- a/src/sage/functions/special.py +++ b/src/sage/functions/special.py @@ -165,7 +165,8 @@ from sage.symbolic.constants import pi from sage.symbolic.function import BuiltinFunction from sage.libs.mpmath import utils as mpmath_utils -from sage.functions.all import sqrt, sin, cot, exp +from sage.functions.all import sin, cot, exp +from sage.misc.functional import sqrt from sage.symbolic.constants import I diff --git a/src/sage/geometry/hyperbolic_space/hyperbolic_coercion.py b/src/sage/geometry/hyperbolic_space/hyperbolic_coercion.py index f3eab52363b..fac28dfd161 100644 --- a/src/sage/geometry/hyperbolic_space/hyperbolic_coercion.py +++ b/src/sage/geometry/hyperbolic_space/hyperbolic_coercion.py @@ -25,7 +25,8 @@ from sage.modules.free_module_element import vector from sage.rings.integer import Integer from sage.rings.infinity import infinity -from sage.functions.other import real, imag, sqrt +from sage.functions.other import real, imag +from sage.misc.functional import sqrt from sage.misc.lazy_import import lazy_import lazy_import('sage.misc.call', 'attrcall') diff --git a/src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py b/src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py index ccb1fcdd95c..bebe858bd28 100644 --- a/src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py +++ b/src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py @@ -93,7 +93,8 @@ from sage.symbolic.constants import pi from sage.modules.free_module_element import vector from sage.matrix.constructor import matrix -from sage.functions.other import real, imag, sqrt +from sage.functions.other import real, imag +from sage.misc.functional import sqrt from sage.functions.trig import arccos from sage.functions.log import exp from sage.functions.hyperbolic import sinh, cosh, arcsinh diff --git a/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py b/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py index 896dc71be58..0af1c29e0c3 100644 --- a/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py +++ b/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py @@ -51,7 +51,8 @@ from sage.rings.infinity import infinity from sage.misc.latex import latex from sage.rings.real_double import RDF -from sage.functions.other import imag, sqrt +from sage.functions.other import imag +from sage.misc.functional import sqrt from sage.functions.all import arccosh, sign from sage.geometry.hyperbolic_space.hyperbolic_constants import EPSILON diff --git a/src/sage/geometry/hyperbolic_space/hyperbolic_model.py b/src/sage/geometry/hyperbolic_space/hyperbolic_model.py index 6a891b88046..7adb33ed6b9 100644 --- a/src/sage/geometry/hyperbolic_space/hyperbolic_model.py +++ b/src/sage/geometry/hyperbolic_space/hyperbolic_model.py @@ -81,7 +81,8 @@ from sage.structure.parent import Parent from sage.misc.bindable_class import BindableClass from sage.misc.lazy_import import lazy_import -from sage.functions.other import imag, real, sqrt +from sage.functions.other import imag, real +from sage.misc.functional import sqrt from sage.functions.all import arccosh from sage.rings.all import CC from sage.rings.real_double import RDF diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index e2e6772defb..c07d3ccfe3f 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -48,7 +48,8 @@ from sage.modules.free_module_element import vector from sage.modules.vector_space_morphism import linear_transformation from sage.matrix.constructor import matrix -from sage.functions.other import sqrt, floor, ceil +from sage.functions.other import floor, ceil +from sage.misc.functional import sqrt from sage.groups.matrix_gps.finitely_generated import MatrixGroup from sage.graphs.graph import Graph from sage.geometry.convex_set import ConvexSet_closed, AffineHullProjectionData diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index 566a07c4d33..46fb03a14c4 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -252,7 +252,8 @@ def _discrete_log_pgroup(self, p, aa, b): (1, 17, 123, 456) """ from sage.arith.misc import valuation - from sage.functions.other import ceil, sqrt + from sage.functions.other import ceil + from sage.misc.functional import sqrt from itertools import product as iproduct vals = [valuation(a.order(), p) for a in aa] diff --git a/src/sage/interfaces/tides.py b/src/sage/interfaces/tides.py index cf7c0f354d5..66e515e874b 100644 --- a/src/sage/interfaces/tides.py +++ b/src/sage/interfaces/tides.py @@ -46,7 +46,8 @@ from sage.ext.fast_callable import fast_callable from sage.rings.semirings.non_negative_integer_semiring import NN from sage.functions.log import log, exp -from sage.functions.other import floor, sqrt, ceil +from sage.functions.other import floor, ceil +from sage.misc.functional import sqrt diff --git a/src/sage/manifolds/utilities.py b/src/sage/manifolds/utilities.py index ae729e33206..7ee44aa9093 100644 --- a/src/sage/manifolds/utilities.py +++ b/src/sage/manifolds/utilities.py @@ -30,7 +30,8 @@ from sage.symbolic.expression_conversions import ExpressionTreeWalker from sage.symbolic.ring import SR from sage.symbolic.constants import pi -from sage.functions.other import sqrt, abs_symbolic +from sage.functions.other import abs_symbolic +from sage.misc.functional import sqrt from sage.functions.trig import cos, sin from sage.rings.all import Rational diff --git a/src/sage/quadratic_forms/quadratic_form__theta.py b/src/sage/quadratic_forms/quadratic_form__theta.py index 8309142f1b5..4915205aa67 100644 --- a/src/sage/quadratic_forms/quadratic_form__theta.py +++ b/src/sage/quadratic_forms/quadratic_form__theta.py @@ -16,7 +16,8 @@ from sage.rings.real_mpfr import RealField from sage.rings.power_series_ring import PowerSeriesRing from sage.rings.integer_ring import ZZ -from sage.functions.all import sqrt, floor, ceil +from sage.functions.all import floor, ceil +from sage.misc.functional import sqrt diff --git a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py index 8a335d4f852..909af780d77 100644 --- a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py +++ b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py @@ -1757,7 +1757,8 @@ def asymptotics_smooth(self, p, alpha, N, asy_var, coordinate=None, """ from sage.calculus.functions import jacobian from sage.calculus.var import function - from sage.functions.other import factorial, sqrt + from sage.functions.other import factorial + from sage.misc.functional import sqrt from sage.functions.gamma import gamma from sage.functions.log import exp, log from sage.matrix.constructor import matrix @@ -2138,7 +2139,8 @@ def asymptotics_multiple(self, p, alpha, N, asy_var, coordinate=None, from sage.calculus.var import function from sage.combinat.combinat import stirling_number1 from sage.functions.log import exp, log - from sage.functions.other import factorial, sqrt + from sage.functions.other import factorial + from sage.misc.functional import sqrt from sage.matrix.constructor import matrix from sage.misc.mrange import xmrange from sage.modules.free_module_element import vector diff --git a/src/sage/rings/invariants/reconstruction.py b/src/sage/rings/invariants/reconstruction.py index b9db4e07521..f8edfc92d98 100644 --- a/src/sage/rings/invariants/reconstruction.py +++ b/src/sage/rings/invariants/reconstruction.py @@ -262,7 +262,8 @@ def binary_quintic_coefficients_from_invariants(invariants, K=None, invariant_ch N = K(2)**-1 * (A*C-B**2) R2 = -K(2)**-1 * (A*N**2-2*B*M*N+C*M**2) scale = [1,1,1,1,1,1] - from sage.functions.all import binomial, sqrt + from sage.functions.all import binomial + from sage.misc.functional import sqrt if len(invariants) == 3: if R2.is_square(): R = sqrt(R2) From 5952b370f8da06cd4b091ebefd67a0865b84604c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 19 Oct 2021 22:48:39 -0700 Subject: [PATCH 05/19] src/sage/misc/all.py: Add sqrt --- src/sage/misc/all.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/misc/all.py b/src/sage/misc/all.py index 375b8e852f1..defe3663e51 100644 --- a/src/sage/misc/all.py +++ b/src/sage/misc/all.py @@ -142,6 +142,7 @@ quo, isqrt, squarefree_part, + sqrt, symbolic_sum as sum, symbolic_prod as product, transpose) From 905e8001c378ff9001e6730e297759a73aad4e37 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 19 Oct 2021 22:48:48 -0700 Subject: [PATCH 06/19] src/sage/misc/functional.py: Fix imports --- src/sage/misc/functional.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py index ec701dade01..59e9d83e460 100644 --- a/src/sage/misc/functional.py +++ b/src/sage/misc/functional.py @@ -21,6 +21,7 @@ # https://www.gnu.org/licenses/ # **************************************************************************** import builtins +import math from sage.rings.complex_double import CDF from sage.rings.real_double import RDF, RealDoubleElement @@ -1722,9 +1723,11 @@ def _do_sqrt(x, prec=None, extend=True, all=False): """ if prec: if x >= 0: - return RealField(prec)(x).sqrt(all=all) + from sage.rings.real_mpfr import RealField + return RealField(prec)(x).sqrt(all=all) else: - return ComplexField(prec)(x).sqrt(all=all) + from sage.rings.complex_mpfr import ComplexField + return ComplexField(prec)(x).sqrt(all=all) if x == -1: from sage.symbolic.expression import I z = I From 451ac273aa6c03f2e54d49e12a4460ff92663b54 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 19 Oct 2021 22:49:03 -0700 Subject: [PATCH 07/19] src/sage/functions/other.py: Remove import from sage.rings.all --- src/sage/functions/other.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sage/functions/other.py b/src/sage/functions/other.py index bb7e5d7d7bd..cd2adbb1bfb 100644 --- a/src/sage/functions/other.py +++ b/src/sage/functions/other.py @@ -21,7 +21,11 @@ from sage.symbolic.function import GinacFunction, BuiltinFunction from sage.symbolic.expression import Expression, register_symbol, symbol_table from sage.symbolic.ring import SR -from sage.rings.all import Integer, Rational, RealField, ZZ, ComplexField +from sage.rings.integer import Integer +from sage.rings.integer_ring import ZZ +from sage.rings.rational import Rational +from sage.rings.complex_mpfr import ComplexField +from sage.rings.real_mpfr import RealField from sage.misc.latex import latex from sage.structure.element import Element import math From 82ea84cfad2c81080f51bfa03255dcf1362c4488 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 19 Oct 2021 23:44:28 -0700 Subject: [PATCH 08/19] src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py: Use integer division instead of floor(.../...) --- .../endPN_automorphism_group.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py b/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py index e5ef59acf59..f820d893503 100644 --- a/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py +++ b/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py @@ -39,7 +39,7 @@ from sage.sets.set import Set from sage.combinat.permutation import Arrangements from sage.parallel.use_fork import p_iter_fork -from sage.functions.other import floor + def automorphism_group_QQ_fixedpoints(rational_function, return_functions=False, iso_type=False): r""" @@ -2213,8 +2213,8 @@ def find_conjugations_arrangement(tuples): # and check linear independence in parallel if len(all_subsets) > num_cpus: for i in range(num_cpus): - start = floor(len(all_subsets)*i/num_cpus) - end = floor(len(all_subsets)*(i+1)/num_cpus) + start = (len(all_subsets) * i) // num_cpus + end = (len(all_subsets) * (i+1)) // num_cpus tuples = all_subsets[start:end] parallel_data.append(([tuples], {})) @@ -2242,8 +2242,8 @@ def find_conjugations_arrangement(tuples): all_arrangements += list(product(*subset_arrangements)) parallel_data = [] for i in range(num_cpus): - start = floor(len(all_arrangements)*i/num_cpus) - end = floor(len(all_arrangements)*(i+1)/num_cpus) + start = (len(all_arrangements) * i) // num_cpus + end = (len(all_arrangements) * (i+1)) // num_cpus tuples = all_arrangements[start:end] parallel_data.append(([tuples], {})) X = p_iter_fork(num_cpus) @@ -2350,8 +2350,8 @@ def find_conjugations_arrangement(tuples): # and check linear independence in parallel if len(all_subsets) > num_cpus: for i in range(num_cpus): - start = floor(len(all_subsets)*i/num_cpus) - end = floor(len(all_subsets)*(i+1)/num_cpus) + start = (len(all_subsets) * i) // num_cpus + end = (len(all_subsets) * (i+1)) // num_cpus tuples = all_subsets[start:end] parallel_data.append(([tuples], {})) @@ -2380,8 +2380,8 @@ def find_conjugations_arrangement(tuples): all_arrangements += list(product(*subset_arrangements)) parallel_data = [] for i in range(num_cpus): - start = floor(len(all_arrangements)*i/num_cpus) - end = floor(len(all_arrangements)*(i+1)/num_cpus) + start = (len(all_arrangements) * i) // num_cpus + end = (len(all_arrangements) * (i+1)) // num_cpus tuples = all_arrangements[start:end] parallel_data.append(([tuples], {})) X = p_iter_fork(num_cpus) From 1b876e41ec68201bf1d1b60461e9ff8a3780b004 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 20 Oct 2021 18:58:02 -0700 Subject: [PATCH 09/19] sage.arith.misc.integer_trun: New, move here from sage.combinat.crystals --- src/sage/arith/misc.py | 18 +++++++++++++++++ src/sage/combinat/crystals/tensor_product.py | 21 +------------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 9a2aa40819d..273055ba387 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -5031,6 +5031,24 @@ def integer_floor(x): raise NotImplementedError("computation of floor of %s not implemented"%x) +def integer_trunc(i): + """ + Truncate to the integer closer to zero + + EXAMPLES:: + + sage: from sage.arith.misc import integer_trunc as trunc + sage: trunc(-3/2), trunc(-1), trunc(-1/2), trunc(0), trunc(1/2), trunc(1), trunc(3/2) + (-1, -1, 0, 0, 0, 1, 1) + sage: isinstance(trunc(3/2), Integer) + True + """ + if i >= 0: + return integer_floor(i) + else: + return integer_ceil(i) + + def two_squares(n): """ Write the integer `n` as a sum of two integer squares if possible; diff --git a/src/sage/combinat/crystals/tensor_product.py b/src/sage/combinat/crystals/tensor_product.py index 9df369573f8..4b8ee8480d8 100644 --- a/src/sage/combinat/crystals/tensor_product.py +++ b/src/sage/combinat/crystals/tensor_product.py @@ -52,27 +52,8 @@ from sage.misc.flatten import flatten from sage.structure.element import get_coercion_model from sage.rings.semirings.non_negative_integer_semiring import NN +from sage.arith.misc import integer_trunc as trunc -############################################################################## -# Until trunc gets implemented in sage.function.other - -from sage.functions.other import floor, ceil -def trunc(i): - """ - Truncates to the integer closer to zero - - EXAMPLES:: - - sage: from sage.combinat.crystals.tensor_product import trunc - sage: trunc(-3/2), trunc(-1), trunc(-1/2), trunc(0), trunc(1/2), trunc(1), trunc(3/2) - (-1, -1, 0, 0, 0, 1, 1) - sage: isinstance(trunc(3/2), Integer) - True - """ - if i>= 0: - return floor(i) - else: - return ceil(i) ############################################################################## # Support classes From 8305ac34dd41816e8482a656e67756a345f30bb4 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 4 Oct 2021 15:12:22 -0700 Subject: [PATCH 10/19] sage.geometry.polyhedron: Remove use of sage.functions --- src/sage/geometry/polyhedron/backend_normaliz.py | 2 +- src/sage/geometry/polyhedron/base.py | 13 ++++++------- .../polyhedron/combinatorial_polyhedron/base.pyx | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/sage/geometry/polyhedron/backend_normaliz.py b/src/sage/geometry/polyhedron/backend_normaliz.py index d1f30e2d31f..58af1b3059c 100644 --- a/src/sage/geometry/polyhedron/backend_normaliz.py +++ b/src/sage/geometry/polyhedron/backend_normaliz.py @@ -1538,7 +1538,7 @@ def _volume_normaliz(self, measure='euclidean'): from sage.rings.infinity import infinity return infinity - from sage.functions.other import factorial + from sage.arith.misc import factorial return self._volume_normaliz('induced_lattice') / factorial(self.dim()) else: diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index c07d3ccfe3f..81f8e630e2a 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -40,7 +40,7 @@ from sage.misc.misc_c import prod from sage.misc.randstate import current_randstate from sage.misc.superseded import deprecated_function_alias - +y from sage.rings.integer_ring import ZZ from sage.rings.qqbar import AA from sage.rings.rational_field import QQ @@ -48,10 +48,9 @@ from sage.modules.free_module_element import vector from sage.modules.vector_space_morphism import linear_transformation from sage.matrix.constructor import matrix -from sage.functions.other import floor, ceil -from sage.misc.functional import sqrt -from sage.groups.matrix_gps.finitely_generated import MatrixGroup -from sage.graphs.graph import Graph +from sage.arith.misc import integer_floor as floor +from sage.arith.misc import integer_ceil as ceil +lazy_import('sage.groups.matrix_gps.finitely_generated', 'MatrixGroup') from sage.geometry.convex_set import ConvexSet_closed, AffineHullProjectionData from .constructor import Polyhedron @@ -3418,7 +3417,7 @@ def radius(self): sage: p.radius() 2 """ - return sqrt(self.radius_square()) + return self.radius_square().sqrt() def is_inscribed(self, certificate=False): """ @@ -8999,7 +8998,7 @@ def integrate(self, function, measure='ambient', **kwds): Adet = AA.coerce(Adet) except TypeError: pass - return I / sqrt(Adet) + return I / Adet.sqrt() else: raise ValueError('unknown measure "{}"'.format(measure)) diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx index 524933a01a8..c63b8a943bd 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx @@ -1854,7 +1854,7 @@ cdef class CombinatorialPolyhedron(SageObject): if self.is_simplex(): return self.dim() + 1 else: - from sage.functions.other import binomial + from sage.arith.misc import binomial k = 1 while self.f_vector()[k+1] == binomial(self.n_vertices(), k + 1): k += 1 @@ -1904,7 +1904,7 @@ cdef class CombinatorialPolyhedron(SageObject): sage: C.is_neighborly(k=2) True """ - from sage.functions.other import binomial + from sage.arith.misc import binomial if k is None: k = self.dim() // 2 return all(self.f_vector()[i+1] == binomial(self.n_vertices(), i + 1) From 00f5615f14bf34dc82b377a2c6b7cd4a32fc0e3b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 20 Oct 2021 19:08:02 -0700 Subject: [PATCH 11/19] src/sage/graphs/hyperbolicity.pyx: Remove unused import --- src/sage/graphs/hyperbolicity.pyx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sage/graphs/hyperbolicity.pyx b/src/sage/graphs/hyperbolicity.pyx index 1f479774b7e..44e33930181 100644 --- a/src/sage/graphs/hyperbolicity.pyx +++ b/src/sage/graphs/hyperbolicity.pyx @@ -158,7 +158,6 @@ from sage.graphs.distances_all_pairs cimport c_distances_all_pairs from sage.arith.all import binomial from sage.rings.integer_ring import ZZ from sage.rings.real_mpfr import RR -from sage.functions.other import floor from sage.data_structures.bitset import Bitset from sage.graphs.base.static_sparse_graph cimport short_digraph from sage.graphs.base.static_sparse_graph cimport init_short_digraph From 27b44b9df1de6b0ebbe83eadde4ceba60a096c45 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 18 Oct 2021 22:19:17 -0700 Subject: [PATCH 12/19] src/sage/modular/pollack_stevens/dist.pyx: Remove unused import --- src/sage/modular/pollack_stevens/dist.pyx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sage/modular/pollack_stevens/dist.pyx b/src/sage/modular/pollack_stevens/dist.pyx index 65942454937..b9165153621 100644 --- a/src/sage/modular/pollack_stevens/dist.pyx +++ b/src/sage/modular/pollack_stevens/dist.pyx @@ -39,7 +39,6 @@ from sage.matrix.matrix cimport Matrix from sage.matrix.matrix_space import MatrixSpace from sage.matrix.constructor import matrix from sage.misc.prandom import random -from sage.functions.other import floor from sage.structure.element cimport RingElement, Element import operator from sage.rings.padics.padic_generic import pAdicGeneric From 7f1d021ee896adb823e20a34367333a2031b943e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 18 Oct 2021 22:19:36 -0700 Subject: [PATCH 13/19] src/sage/quadratic_forms/ternary.pyx: Remove unused import --- src/sage/quadratic_forms/ternary.pyx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sage/quadratic_forms/ternary.pyx b/src/sage/quadratic_forms/ternary.pyx index 63b59b82525..80405d61158 100644 --- a/src/sage/quadratic_forms/ternary.pyx +++ b/src/sage/quadratic_forms/ternary.pyx @@ -19,7 +19,6 @@ from sage.arith.all import inverse_mod, xgcd, gcd from sage.quadratic_forms.extras import extend_to_primitive from sage.rings.finite_rings.integer_mod import mod from sage.misc.prandom import randint -from sage.functions.other import ceil, floor def red_mfact(a,b): From d5cfe2a94a61a066cf0fbab4eb1cedd7a62e8886 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 18 Oct 2021 22:20:19 -0700 Subject: [PATCH 14/19] src/sage/combinat/crystals/tensor_product_element.pyx: Remove unused import --- src/sage/combinat/crystals/tensor_product_element.pyx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sage/combinat/crystals/tensor_product_element.pyx b/src/sage/combinat/crystals/tensor_product_element.pyx index ed3e688ee56..8a6f7043491 100644 --- a/src/sage/combinat/crystals/tensor_product_element.pyx +++ b/src/sage/combinat/crystals/tensor_product_element.pyx @@ -34,7 +34,6 @@ from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE from sage.structure.parent cimport Parent from sage.misc.cachefunc import cached_method, cached_in_parent_method -from sage.functions.other import ceil from sage.combinat.tableau import Tableau from sage.rings.integer_ring import ZZ From d825aa8bdcd7c6ef1ae2d9254940921457448829 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 20 Oct 2021 19:10:35 -0700 Subject: [PATCH 15/19] src/sage/combinat/crystals/littelmann_path.py: Use integer_floor instead of sage.functions.other.floor --- src/sage/combinat/crystals/littelmann_path.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/crystals/littelmann_path.py b/src/sage/combinat/crystals/littelmann_path.py index 4efbef4a0c3..04cddcf7278 100644 --- a/src/sage/combinat/crystals/littelmann_path.py +++ b/src/sage/combinat/crystals/littelmann_path.py @@ -40,7 +40,7 @@ from sage.rings.integer import Integer from sage.rings.rational_field import QQ from sage.combinat.root_system.root_system import RootSystem -from sage.functions.other import floor +from sage.arith.misc import integer_floor as floor from sage.misc.latex import latex From 9c35213ad90d917f46d5875616c3bdc7320da411 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 20 Oct 2021 19:11:01 -0700 Subject: [PATCH 16/19] src/sage/combinat/diagram_algebras.py: Use integer_floor, integer_ceil instead of importing from sage.functions --- src/sage/combinat/diagram_algebras.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sage/combinat/diagram_algebras.py b/src/sage/combinat/diagram_algebras.py index 17a9f85bc5f..ea5303bf1bc 100644 --- a/src/sage/combinat/diagram_algebras.py +++ b/src/sage/combinat/diagram_algebras.py @@ -43,7 +43,8 @@ from sage.misc.misc_c import prod from sage.rings.integer_ring import ZZ from sage.rings.rational_field import QQ -from sage.functions.other import floor, ceil +from sage.arith.misc import integer_floor as floor +from sage.arith.misc import integer_ceil as ceil import itertools From 57551d338a8bc8d105fbdc5cff8bc6e8b42d8608 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 20 Oct 2021 19:11:16 -0700 Subject: [PATCH 17/19] src/sage/graphs/generic_graph.py: Use integer_floor instead of sage.functions.other.floor --- src/sage/graphs/generic_graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index 33f06c06dda..1a1ff3f292d 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -9272,7 +9272,7 @@ def _ford_fulkerson(self, s, t, use_edge_labels=False, integer=False, value_only 0 """ from sage.graphs.digraph import DiGraph - from sage.functions.other import floor + from sage.arith.misc import integer_floor as floor # Whether we should consider the edges labeled if use_edge_labels: From bed7308f0d57dc8e4d1c052121217a07156fc888 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 25 Oct 2021 14:21:08 -0700 Subject: [PATCH 18/19] src/sage/geometry/polyhedron/base.py: Remove stray character --- src/sage/geometry/polyhedron/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 81f8e630e2a..7de1c996072 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -40,7 +40,7 @@ from sage.misc.misc_c import prod from sage.misc.randstate import current_randstate from sage.misc.superseded import deprecated_function_alias -y + from sage.rings.integer_ring import ZZ from sage.rings.qqbar import AA from sage.rings.rational_field import QQ From 33a2e7bc53d3eb3f23e80e6a8208b4e1608b82c0 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 25 Oct 2021 18:45:20 -0700 Subject: [PATCH 19/19] src/sage/geometry/polyhedron/base.py: Fix up imports --- src/sage/geometry/polyhedron/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py index 7de1c996072..085c117a087 100644 --- a/src/sage/geometry/polyhedron/base.py +++ b/src/sage/geometry/polyhedron/base.py @@ -50,6 +50,7 @@ from sage.matrix.constructor import matrix from sage.arith.misc import integer_floor as floor from sage.arith.misc import integer_ceil as ceil +from sage.misc.lazy_import import lazy_import lazy_import('sage.groups.matrix_gps.finitely_generated', 'MatrixGroup') from sage.geometry.convex_set import ConvexSet_closed, AffineHullProjectionData @@ -10537,6 +10538,7 @@ def edge_label(i, j, c_ij): Qplus = sum(v.column() * v.row() for v in V).pseudoinverse() # Construct the graph. + from sage.graphs.graph import Graph G = Graph() for i in range(len(V)): for j in range(i+1, len(V)):