From 901eaf8760dc96dac0fc3757fc5f90ddf1cf850c Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Mon, 11 Mar 2019 09:32:59 +0100 Subject: [PATCH] Print numbers consistently on Python 2 and 3 --- src/sage/schemes/elliptic_curves/height.py | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/sage/schemes/elliptic_curves/height.py b/src/sage/schemes/elliptic_curves/height.py index 8effb4afb45..90c2d1a5066 100644 --- a/src/sage/schemes/elliptic_curves/height.py +++ b/src/sage/schemes/elliptic_curves/height.py @@ -1902,7 +1902,7 @@ def min_gr(self, tol, n_max, verbose=False): sage: K. = QuadraticField(-1) sage: E = EllipticCurve([0,1-i,i,-i,0]) sage: H = E.height_function() - sage: H.min_gr(0.01,5) + sage: H.min_gr(0.01, 5) # long time 0.020153685521979152 In this example the point `P=(0,0)` has height 0.023 so our @@ -1927,11 +1927,10 @@ def min_gr(self, tol, n_max, verbose=False): This example from the LMFDB gave problems before the fix in :trac:`8829`:: - sage: K. = NumberField(x^2-x-1) - sage: phi = a + sage: K. = NumberField(x^2-x-1) sage: E = EllipticCurve([phi + 1, -phi + 1, 1, 20*phi - 39, 196*phi + 237]) sage: H = E.height_function() - sage: H.min_gr(.1,5,True) # long time (~22s) + sage: H.min_gr(.1, 5, verbose=True) # long time (~22s) B_1(1) = 1540.199246369678 ... halving mu to 0.25 and increasing n_max to 6 @@ -1941,42 +1940,42 @@ def min_gr(self, tol, n_max, verbose=False): doubling mu to 0.015625 height bound in [0.0078125, 0.015625] using n_max = 13 ... - height bound in [0.0120485220735, 0.0131390064883] using n_max = 13 + height bound in [0.012048522073499539, 0.01313900648833929] using n_max = 13 0.012048522073499539 """ test = self.test_mu if test(1, n_max, verbose): - mu = 2 + mu = 2.0 while test(mu, n_max, False): mu *= 2 - mu /= 2 + mu *= 0.5 else: - mu = .5 + mu = 0.5 while not test(mu, n_max, False): - mu /= 2 + mu *= 0.5 n_max += 1 if verbose: - print("halving mu to %s and increasing n_max to %s" % (mu,n_max)) + print("halving mu to %r and increasing n_max to %r" % (mu, n_max)) # now we have (mu,n_max) which work we can try to increase # mu again using this larger n_max: mu *= 2 while test(mu, n_max, False): mu *= 2 if verbose: - print("doubling mu to %s" % mu) - mu /= 2 + print("doubling mu to %r" % mu) + mu *= 0.5 # The true value lies between mu and eps * mu. eps = 2.0 while eps > tol + 1: if verbose: - print("height bound in [%s, %s] using n_max = %s" + print("height bound in [%r, %r] using n_max = %r" % (mu, mu * eps, n_max)) eps = math.sqrt(eps) if test(mu * eps, n_max, False): mu = mu * eps if verbose: - print("height bound in [%s, %s] using n_max = %s" + print("height bound in [%r, %r] using n_max = %r" % (mu, mu * eps, n_max)) return RDF(mu)