diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py index 765485f0374..c329d757735 100644 --- a/src/sage/schemes/elliptic_curves/ell_rational_field.py +++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py @@ -3055,12 +3055,12 @@ def selmer_rank(self, algorithm="pari"): try: return self.__selmer_rank except AttributeError: - if algorithm=="pari": + if algorithm == "pari": ep = self.pari_curve() lower, upper, s, pts = ep.ellrank() tor = self.two_torsion_rank() return upper + tor + s - elif algorithm=="mwrank": + elif algorithm == "mwrank": C = self.mwrank_curve() self.__selmer_rank = C.selmer_rank() return self.__selmer_rank @@ -3110,11 +3110,11 @@ def rank_bound(self, algorithm="pari"): try: return self.__rank_bound except AttributeError: - if algorithm=="pari": + if algorithm == "pari": ep = self.pari_curve() lower, upper, s, pts = ep.ellrank() return upper - elif algorithm=="mwrank": + elif algorithm == "mwrank": C = self.mwrank_curve() self.__rank_bound = C.rank_bound() return self.__rank_bound diff --git a/src/sage/schemes/elliptic_curves/padics.py b/src/sage/schemes/elliptic_curves/padics.py index 51f7cc3db90..2264d998ef4 100644 --- a/src/sage/schemes/elliptic_curves/padics.py +++ b/src/sage/schemes/elliptic_curves/padics.py @@ -643,7 +643,7 @@ def _multiple_to_make_good_reduction(E): li = [] for p in ps: np = u.valuation(p) - if Emin.discriminant() %p != 0: + if Emin.discriminant() % p != 0: li.append(Emin.Np(p) * p**(np-1)) elif Emin.has_additive_reduction(p): li.append(E.tamagawa_number(p) * p**np) @@ -652,7 +652,7 @@ def _multiple_to_make_good_reduction(E): else: # non split li.append(E.tamagawa_number(p) * (p+1) * p**(np-1)) otherbad = Integer(Emin.discriminant()).prime_divisors() - otherbad = [p for p in otherbad if u%p != 0 ] + otherbad = [p for p in otherbad if u % p != 0 ] li += [E.tamagawa_number(p) for p in otherbad] n2 = LCM(li) return n2 diff --git a/src/sage/schemes/generic/algebraic_scheme.py b/src/sage/schemes/generic/algebraic_scheme.py index c1434b7c5b4..55699a9b3a0 100644 --- a/src/sage/schemes/generic/algebraic_scheme.py +++ b/src/sage/schemes/generic/algebraic_scheme.py @@ -530,7 +530,7 @@ def _repr_(self): sage: S._repr_() 'Subscheme of Projective Space of dimension 3 over Integer Ring' """ - return "Subscheme of %s"%self.__A + return "Subscheme of %s" % self.__A def _homset(self, *args, **kwds): """ @@ -821,11 +821,11 @@ def _check_satisfies_equations(self, v): coords = list(v) for f in self.__X.defining_polynomials(): if f(coords) != 0: - raise TypeError("Coordinates %s do not define a point on %s"%(v,self)) + raise TypeError("Coordinates %s do not define a point on %s" % (v,self)) for f in self.__Y.defining_polynomials(): if f(coords) != 0: return True - raise TypeError("Coordinates %s do not define a point on %s"%(v,self)) + raise TypeError("Coordinates %s do not define a point on %s" % (v,self)) def rational_points(self, **kwds): """ @@ -872,9 +872,9 @@ def rational_points(self, **kwds): if bound == 0: if is_RationalField(F): - raise TypeError("A positive bound (= %s) must be specified."%bound) + raise TypeError("A positive bound (= %s) must be specified." % bound) if not isinstance(F, FiniteField): - raise TypeError("Argument F (= %s) must be a finite field."%F) + raise TypeError("Argument F (= %s) must be a finite field." % F) pts = [] for P in self.ambient_space().rational_points(F): try: @@ -986,11 +986,11 @@ def _check_satisfies_equations(self, v): for f in self.defining_polynomials(): if f(coords) != 0: # it must be "!=0" instead of "if f(v)", e.g., # because of p-adic base rings. - raise TypeError("Coordinates %s do not define a point on %s"%(coords,self)) + raise TypeError("Coordinates %s do not define a point on %s" % (coords,self)) try: return self.ambient_space()._check_satisfies_equations(coords) except TypeError: - raise TypeError("Coordinates %s do not define a point on %s"%(coords,self)) + raise TypeError("Coordinates %s do not define a point on %s" % (coords,self)) def base_extend(self, R): """ @@ -1465,10 +1465,10 @@ def union(self, other): True """ if not isinstance(other, AlgebraicScheme_subscheme): - raise TypeError("other (=%s) must be a closed algebraic subscheme of an ambient space"%other) + raise TypeError("other (=%s) must be a closed algebraic subscheme of an ambient space" % other) A = self.ambient_space() if other.ambient_space() != A: - raise ValueError("other (=%s) must be in the same ambient space as self"%other) + raise ValueError("other (=%s) must be in the same ambient space as self" % other) return A.subscheme(self.defining_ideal().intersection(other.defining_ideal())) def __pow__(self, m): @@ -1649,10 +1649,10 @@ def intersection(self, other): y """ if not isinstance(other, AlgebraicScheme_subscheme): - raise TypeError("other (=%s) must be a closed algebraic subscheme of an ambient space"%other) + raise TypeError("other (=%s) must be a closed algebraic subscheme of an ambient space" % other) A = self.ambient_space() if other.ambient_space() != A: - raise ValueError("other (=%s) must be in the same ambient space as self"%other) + raise ValueError("other (=%s) must be in the same ambient space as self" % other) return A.subscheme(self.defining_ideal() + other.defining_ideal()) def complement(self, other=None): @@ -1708,9 +1708,9 @@ def complement(self, other=None): if other == A: other = A.subscheme([]) else: - raise TypeError("Argument other (=%s) must be a closed algebraic subscheme of an ambient space"%other) + raise TypeError("Argument other (=%s) must be a closed algebraic subscheme of an ambient space" % other) if other.ambient_space() != A: - raise ValueError("other (=%s) must be in the same ambient space as self"%other) + raise ValueError("other (=%s) must be in the same ambient space as self" % other) return AlgebraicScheme_quasi(other, self) def rational_points(self, **kwds): @@ -1831,7 +1831,7 @@ def rational_points(self, **kwds): try: return X.points(**kwds) # checks for proper bound done in points functions except TypeError: - raise TypeError("Unable to enumerate points over %s."%F) + raise TypeError("Unable to enumerate points over %s." % F) elif (self.base_ring() in NumberFields() or self.base_ring() == ZZ)\ and hasattr(F, 'precision'): #we are numerically approximating number field points @@ -1840,7 +1840,7 @@ def rational_points(self, **kwds): X = self.base_extend(F)(F) return X.points() except TypeError: - raise TypeError("Unable to enumerate points over %s."%F) + raise TypeError("Unable to enumerate points over %s." % F) def change_ring(self, R): r""" diff --git a/src/sage/schemes/generic/glue.py b/src/sage/schemes/generic/glue.py index d3169ba0116..76bd9a1ab9e 100644 --- a/src/sage/schemes/generic/glue.py +++ b/src/sage/schemes/generic/glue.py @@ -33,11 +33,11 @@ class GluedScheme(scheme.Scheme): def __init__(self, f, g, check=True): if check: if not morphism.is_SchemeMorphism(f): - raise TypeError("f (=%s) must be a scheme morphism"%f) + raise TypeError("f (=%s) must be a scheme morphism" % f) if not morphism.is_SchemeMorphism(g): - raise TypeError("g (=%s) must be a scheme morphism"%g) + raise TypeError("g (=%s) must be a scheme morphism" % g) if f.domain() != g.domain(): - raise ValueError("f (=%s) and g (=%s) must have the same domain"%(f,g)) + raise ValueError("f (=%s) and g (=%s) must have the same domain" % (f,g)) self.__f = f self.__g = g @@ -45,5 +45,5 @@ def gluing_maps(self): return self.__f, self.__g def _repr_(self): - return "Scheme obtained by gluing X and Y along U, where\n X: %s\n Y: %s\n U: %s"%( + return "Scheme obtained by gluing X and Y along U, where\n X: %s\n Y: %s\n U: %s" % ( self.__f.codomain(), self.__g.codomain(), self.__f.domain()) diff --git a/src/sage/schemes/generic/hypersurface.py b/src/sage/schemes/generic/hypersurface.py index fa2326d43e5..48070686a2d 100644 --- a/src/sage/schemes/generic/hypersurface.py +++ b/src/sage/schemes/generic/hypersurface.py @@ -94,9 +94,9 @@ def __init__(self, poly, ambient=None): True """ if not isinstance(poly, MPolynomial): - raise TypeError("Defining polynomial (=%s) must be a multivariate polynomial."%poly) + raise TypeError("Defining polynomial (=%s) must be a multivariate polynomial." % poly) if not poly.is_homogeneous(): - raise TypeError("Defining polynomial (=%s) must be homogeneous."%poly) + raise TypeError("Defining polynomial (=%s) must be homogeneous." % poly) if ambient is None: R = poly.parent() from sage.schemes.projective.projective_space import ProjectiveSpace @@ -119,7 +119,7 @@ def _repr_(self): sage: H._repr_() 'Projective hypersurface defined by y^2 + x*z in Projective Space of dimension 2 over Integer Ring' """ - return "Projective hypersurface defined by %s in %s"%( + return "Projective hypersurface defined by %s in %s" % ( self.defining_polynomial(), self.ambient_space()) def defining_polynomial(self): @@ -184,7 +184,7 @@ def __init__(self, poly, ambient=None): True """ if not isinstance(poly, MPolynomial): - raise TypeError("Defining polynomial (= %s) must be a multivariate polynomial"%poly) + raise TypeError("Defining polynomial (= %s) must be a multivariate polynomial" % poly) if ambient is None: R = poly.parent() from sage.schemes.affine.affine_space import AffineSpace @@ -207,7 +207,7 @@ def _repr_(self): sage: H._repr_() 'Affine hypersurface defined by y^2 + x*z in Affine Space of dimension 3 over Integer Ring' """ - return "Affine hypersurface defined by %s in %s"%( + return "Affine hypersurface defined by %s in %s" % ( self.defining_polynomial(), self.ambient_space()) def defining_polynomial(self): diff --git a/src/sage/schemes/generic/morphism.py b/src/sage/schemes/generic/morphism.py index 086c2960755..800ccee6e2b 100644 --- a/src/sage/schemes/generic/morphism.py +++ b/src/sage/schemes/generic/morphism.py @@ -165,7 +165,7 @@ def __init__(self, parent, codomain=None): if codomain is not None: parent = Hom(parent, codomain) if not isinstance(parent, Homset): - raise TypeError("parent (=%s) must be a Homspace"%parent) + raise TypeError("parent (=%s) must be a Homspace" % parent) Element.__init__(self, parent) self._codomain = parent.codomain() @@ -261,9 +261,9 @@ def __call__(self, x, *args, **kwds): try: x = D(x) except (TypeError, NotImplementedError): - raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(x, self.domain())) - elif self.domain()!=x.codomain(): - raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(x, self.domain())) + raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented" % (x, self.domain())) + elif self.domain() != x.codomain(): + raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented" % (x, self.domain())) else: x = converter(x) if not args and not kwds: @@ -330,14 +330,14 @@ def _repr_(self): NotImplementedError """ if self.is_endomorphism(): - s = "%s endomorphism of %s"%(self._repr_type(), self.domain()) + s = "%s endomorphism of %s" % (self._repr_type(), self.domain()) else: - s = "%s morphism:"%self._repr_type() - s += "\n From: %s"%self.domain() - s += "\n To: %s"%self._codomain + s = "%s morphism:" % self._repr_type() + s += "\n From: %s" % self.domain() + s += "\n To: %s" % self._codomain d = self._repr_defn() if d != '': - s += "\n Defn: %s"%('\n '.join(self._repr_defn().split('\n'))) + s += "\n Defn: %s" % ('\n '.join(self._repr_defn().split('\n'))) return s def __mul__(self, right): @@ -396,7 +396,7 @@ def __mul__(self, right): if not isinstance(right, SchemeMorphism): return coercion_model.bin_op(self, right, operator.mul) if right.codomain() != self.domain(): - raise TypeError("self (=%s) domain must equal right (=%s) codomain"%(self, right)) + raise TypeError("self (=%s) domain must equal right (=%s) codomain" % (self, right)) if isinstance(self, SchemeMorphism_id): return right if isinstance(right, SchemeMorphism_id): @@ -428,7 +428,7 @@ def __pow__(self, n, dummy=None): """ if not self.is_endomorphism(): raise TypeError("self must be an endomorphism.") - if n==0: + if n == 0: return self.domain().identity_morphism() return generic_power(self, n) @@ -995,11 +995,11 @@ def __init__(self, parent, polys, check=True): """ if check: if not isinstance(polys, (list, tuple)): - raise TypeError("polys (=%s) must be a list or tuple"%polys) + raise TypeError("polys (=%s) must be a list or tuple" % polys) source_ring = parent.domain().ambient_space().coordinate_ring() target = parent._codomain.ambient_space() if len(polys) != target.ngens(): - raise ValueError("there must be %s polynomials"%target.ngens()) + raise ValueError("there must be %s polynomials" % target.ngens()) F = [] for poly in polys: try: @@ -1011,7 +1011,7 @@ def __init__(self, parent, polys, check=True): try: p = source_ring(poly.numerator()) / source_ring(poly.denominator()) except (TypeError, AttributeError): - raise TypeError("polys (=%s) must be elements of %s"%(polys, source_ring)) + raise TypeError("polys (=%s) must be elements of %s" % (polys, source_ring)) F.append(p) polys = Sequence(F) @@ -1244,7 +1244,7 @@ def _repr_defn(self): """ i = self.domain().ambient_space()._repr_generic_point() o = self._codomain.ambient_space()._repr_generic_point(self.defining_polynomials()) - return "Defined on coordinates by sending %s to\n%s"%(i,o) + return "Defined on coordinates by sending %s to\n%s" % (i,o) def __getitem__(self, i): """ diff --git a/src/sage/schemes/generic/point.py b/src/sage/schemes/generic/point.py index c3f628159aa..c65963e3eaa 100644 --- a/src/sage/schemes/generic/point.py +++ b/src/sage/schemes/generic/point.py @@ -66,7 +66,7 @@ def _repr_(self): sage: P._repr_() 'Point on Spectrum of Integer Ring' """ - return "Point on %s"%self.__S + return "Point on %s" % self.__S ######################################################## # Topological points on a scheme @@ -179,7 +179,7 @@ def __init__(self, S, P, check=False): # unfortunately is_prime() is only implemented in a small # number of cases if check and not P.is_prime(): - raise ValueError("The argument %s must be a prime ideal of %s"%(P, R)) + raise ValueError("The argument %s must be a prime ideal of %s" % (P, R)) SchemeTopologicalPoint.__init__(self, S) self.__P = P @@ -197,7 +197,7 @@ def _repr_(self): sage: pt._repr_() 'Point on Projective Space of dimension 2 over Rational Field defined by the Ideal (-x^2 + y*z) of Multivariate Polynomial Ring in x, y, z over Rational Field' """ - return "Point on %s defined by the %s"%(self.scheme(), + return "Point on %s defined by the %s" % (self.scheme(), self.prime_ideal()) def prime_ideal(self): @@ -247,7 +247,7 @@ def __init__(self, f): self.__f = f def _repr_(self): - return "Point on %s defined by the morphism %s"%(self.scheme(), + return "Point on %s defined by the morphism %s" % (self.scheme(), self.morphism()) def morphism(self): diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py index ddb2cd61479..69e6813a4d4 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py @@ -644,7 +644,7 @@ def _points_fast_sqrt(self): # (0:1:0) is a point on the curve points = [self.point([K(0), K(1), K(0)], check=True)] else: - points=[] + points = [] if P.degree() > 2: # P(1, y, 0) = r*y + s s = P(K(1), K(0), K(0)) @@ -1109,7 +1109,7 @@ def count_points_hypellfrob(self, n=1, N=None, algorithm=None): raise ValueError("Unknown algorithm") if p <= (2*g+1)*(2*N-1): - raise ValueError("p=%d should be greater than (2*g+1)(2*N-1)=%d"%(p,(2*g+1)*(2*N-1))) + raise ValueError("p=%d should be greater than (2*g+1)(2*N-1)=%d" % (p,(2*g+1)*(2*N-1))) if algorithm == 'traces': M = self.frobenius_matrix(N=N, algorithm='hypellfrob') @@ -1535,16 +1535,16 @@ def _Cartier_matrix_cached(self): #retrieve the function f(x) ,where y^2=f(x) f,h = self.hyperelliptic_polynomials() #This implementation only deals with h=0 - if h!=0: + if h != 0: raise ValueError("E must be of the form y^2 = f(x)") d = f.degree() #this implementation is for odd degree only, even degree will be handled later. - if d%2 == 0: + if d % 2 == 0: raise ValueError("In this implementation the degree of f must be odd") #Compute resultant to make sure no repeated roots - df=f.derivative() - R=df.resultant(f) + df = f.derivative() + R = df.resultant(f) if R == 0: raise ValueError("curve is not smooth") @@ -1566,9 +1566,9 @@ def _Cartier_matrix_cached(self): # compute each row of matrix as list and then M=list of lists(rows) - M=[] + M = [] for j in range(1,g+1): - H=[Coeff[i] for i in range((p*j-1), (p*j-g-1),-1)] + H = [Coeff[i] for i in range((p*j-1), (p*j-g-1),-1)] M.append(H) return matrix(Fq,M), Coeff, g, Fq,p, self @@ -1657,10 +1657,10 @@ def Cartier_matrix(self): # Github Issue #11115: Why shall we waste time by studying # the cache manually? We only need to check whether the cached # data belong to self. - M, Coeffs,g, Fq, p, E= self._Cartier_matrix_cached() - if E!=self: + M, Coeffs,g, Fq, p, E = self._Cartier_matrix_cached() + if E != self: self._Cartier_matrix_cached.clear_cache() - M, Coeffs,g, Fq, p, E= self._Cartier_matrix_cached() + M, Coeffs,g, Fq, p, E = self._Cartier_matrix_cached() return M @cached_method @@ -1824,10 +1824,10 @@ def Hasse_Witt(self): # from the cache - but apparently it could be # that the cached value does not belong to self. # So, the easiest is: - N, E= self._Hasse_Witt_cached() - if E!=self: + N, E = self._Hasse_Witt_cached() + if E != self: self._Hasse_Witt_cached.clear_cache() - N, E= self._Hasse_Witt_cached() + N, E = self._Hasse_Witt_cached() return N def a_number(self): @@ -1866,10 +1866,10 @@ def a_number(self): # Since Github Issue #11115, there is a special cache for methods # that don't accept arguments. The easiest is: Call the cached # method, and test whether the last entry is self. - M,Coeffs,g, Fq, p,E= self._Cartier_matrix_cached() + M,Coeffs,g, Fq, p,E = self._Cartier_matrix_cached() if E != self: self._Cartier_matrix_cached.clear_cache() - M,Coeffs,g, Fq, p,E= self._Cartier_matrix_cached() + M,Coeffs,g, Fq, p,E = self._Cartier_matrix_cached() return g - rank(M) def p_rank(self): diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py index 19d767ea2f3..cab0fb1059f 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py @@ -27,7 +27,7 @@ def is_odd_degree(self): f, h = self.hyperelliptic_polynomials() df = f.degree() if h.degree() < 3: - return df%2 == 1 + return df % 2 == 1 elif df < 6: return False else: diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py index a56fee001cf..ea3987a06c7 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py @@ -147,7 +147,7 @@ def change_ring(self, R): f, h = self._hyperelliptic_polynomials y = self._printing_ring.variable_name() x = self._printing_ring.base_ring().variable_name() - return HyperellipticCurve(f.change_ring(R), h.change_ring(R), "%s,%s"%(x,y)) + return HyperellipticCurve(f.change_ring(R), h.change_ring(R), "%s,%s" % (x,y)) base_extend = change_ring @@ -268,7 +268,7 @@ def lift_x(self, x, all=False): if all: return [] else: - raise ValueError("No point with x-coordinate %s on %s"%(x, self)) + raise ValueError("No point with x-coordinate %s on %s" % (x, self)) def genus(self): return self._genus @@ -397,7 +397,7 @@ def _magma_init_(self, magma): defined by y^2 + x^10*y = x^3 + x + 2 """ f, h = self._hyperelliptic_polynomials - return 'HyperellipticCurve(%s, %s)'%(f._magma_init_(magma), h._magma_init_(magma)) + return 'HyperellipticCurve(%s, %s)' % (f._magma_init_(magma), h._magma_init_(magma)) def monsky_washnitzer_gens(self): import sage.schemes.hyperelliptic_curves.monsky_washnitzer as monsky_washnitzer @@ -462,7 +462,7 @@ def local_coordinates_at_nonweierstrass(self, P, prec=20, name='t'): """ d = P[1] if d == 0: - raise TypeError("P = %s is a Weierstrass point. Use local_coordinates_at_weierstrass instead!"%P) + raise TypeError("P = %s is a Weierstrass point. Use local_coordinates_at_weierstrass instead!" % P) pol = self.hyperelliptic_polynomials()[0] L = PowerSeriesRing(self.base_ring(), name, default_prec=prec) t = L.gen() @@ -514,7 +514,7 @@ def local_coordinates_at_weierstrass(self, P, prec=20, name='t'): - Francis Clarke (2012-08-26) """ if P[1] != 0: - raise TypeError("P = %s is not a finite Weierstrass point. Use local_coordinates_at_nonweierstrass instead!"%P) + raise TypeError("P = %s is not a finite Weierstrass point. Use local_coordinates_at_nonweierstrass instead!" % P) L = PowerSeriesRing(self.base_ring(), name) t = L.gen() pol = self.hyperelliptic_polynomials()[0] diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py index 5111e08faf1..18dbbb59939 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py @@ -123,7 +123,7 @@ def local_analytic_interpolation(self, P, Q): """ prec = self.base_ring().precision_cap() if not self.is_same_disc(P,Q): - raise ValueError("%s and %s are not in the same residue disc"%(P,Q)) + raise ValueError("%s and %s are not in the same residue disc" % (P,Q)) disc = self.residue_disc(P) t = PowerSeriesRing(self.base_ring(), 't', prec).gen(0) if disc == self.change_ring(self.base_ring().residue_field())(0,1,0): # Infinite disc @@ -254,7 +254,7 @@ def find_char_zero_weier_point(self, Q): - Jennifer Balakrishnan """ if not self.is_in_weierstrass_disc(Q): - raise ValueError("%s is not in a Weierstrass disc"%Q) + raise ValueError("%s is not in a Weierstrass disc" % Q) points = self.weierstrass_points() for P in points: if self.is_same_disc(P,Q): @@ -298,7 +298,7 @@ def residue_disc(self, P): return HF(0,0,1) if xPv == 0: return HF(P[0].expansion(0), 0,1) - elif yPv ==0: + elif yPv == 0: if xPv > 0: return HF(0, P[1].expansion(0),1) if xPv == 0: @@ -604,7 +604,7 @@ def coleman_integrals_on_basis(self, P, Q, algorithm=None): offset = (2*g-1)*max(TPv, TQv) if offset == +Infinity: offset = (2*g-1)*min(TPv,TQv) - if (offset > prec and (xTPv <0 or xTQv <0) and (self.residue_disc(P) == self.change_ring(GF(p))(0,1,0) or self.residue_disc(Q) == self.change_ring(GF(p))(0,1,0))): + if (offset > prec and (xTPv < 0 or xTQv < 0) and (self.residue_disc(P) == self.change_ring(GF(p))(0,1,0) or self.residue_disc(Q) == self.change_ring(GF(p))(0,1,0))): newprec = offset + prec K = pAdicField(p,newprec) A = PolynomialRing(RationalField(),'x') @@ -932,10 +932,10 @@ def _frob(P): y0 = P[1] try: uN = (1 + h(x0)/y0**(2*p)).sqrt() - yres=y0**p * uN - xres=x0**p + yres = y0**p * uN + xres = x0**p if (yres-y0).valuation() == 0: - yres=-yres + yres = -yres return self.point([xres,yres, K(1)]) except (TypeError, NotImplementedError): uN2 = 1 + h(x0)/y0**(2*p) @@ -944,7 +944,7 @@ def _frob(P): v = uN2.valuation() a = uN2.parent().gen() uN = self.newton_sqrt(uN2,c.sqrt()*a**(v//2),K.precision_cap()) - yres = y0**p *uN + yres = y0**p * uN xres = x0**p if (yres - y0).valuation() == 0: yres = -yres @@ -1112,7 +1112,7 @@ def P_to_S(self, P, S): """ prec = self.base_ring().precision_cap() deg = (S[0]).parent().defining_polynomial().degree() - prec2= prec*deg + prec2 = prec*deg x,y = self.local_coord(P,prec2) g = self.genus() integrals = [((x**k*x.derivative()/(2*y)).integral()) for k in range(2*g)] diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_rational_field.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_rational_field.py index a55a93dd996..f9337b0fbc0 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_rational_field.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_rational_field.py @@ -27,7 +27,7 @@ def my_chage_ring(self, R): f, h = self._hyperelliptic_polynomials y = self._printing_ring.gen() x = self._printing_ring.base_ring().gen() - return HyperellipticCurve(f.change_ring(R), h, "%s,%s"%(x,y)) + return HyperellipticCurve(f.change_ring(R), h, "%s,%s" % (x,y)) import sage.schemes.hyperelliptic_curves.monsky_washnitzer as monsky_washnitzer if isinstance(p, (sage.rings.abc.pAdicField, sage.rings.abc.pAdicRing)): diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_endomorphism_utils.py b/src/sage/schemes/hyperelliptic_curves/jacobian_endomorphism_utils.py index 5c7c4b22c5c..8d8d89896db 100644 --- a/src/sage/schemes/hyperelliptic_curves/jacobian_endomorphism_utils.py +++ b/src/sage/schemes/hyperelliptic_curves/jacobian_endomorphism_utils.py @@ -122,7 +122,7 @@ def satisfies_coefficient_condition(g, p): return False if g[3]*p != g[1]: return False - if g[2]%p == 0: + if g[2] % p == 0: return False return True diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py b/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py index da1f8908a7a..970a54d9167 100644 --- a/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py +++ b/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py @@ -264,7 +264,7 @@ def cantor_composition_simple(D1,D2,f,genus): d, l, h3 = d0.xgcd(b1 + b2) a = (a1*a2) // (d**2) b = ((b2 + l*h2*(b1-b2)*(a2 // d)) + h3*((f - b2**2) // d)) % (a) - a =a.monic() + a = a.monic() return (a, b) def cantor_composition(D1,D2,f,h,genus): @@ -394,8 +394,8 @@ def __init__(self, parent, polys, check=True): C = parent.curve() f, h = C.hyperelliptic_polynomials() a, b = polys - if not (b**2 + h*b - f)%a == 0: - raise ValueError("Argument polys (= %s) must be divisor on curve %s."%( + if not (b**2 + h*b - f) % a == 0: + raise ValueError("Argument polys (= %s) must be divisor on curve %s." % ( polys, C)) genus = C.genus() if a.degree() > genus: diff --git a/src/sage/schemes/hyperelliptic_curves/mestre.py b/src/sage/schemes/hyperelliptic_curves/mestre.py index 166681b32a1..1694f1dfef7 100644 --- a/src/sage/schemes/hyperelliptic_curves/mestre.py +++ b/src/sage/schemes/hyperelliptic_curves/mestre.py @@ -188,7 +188,7 @@ def HyperellipticCurve_from_invariants(i, reduced=True, precision=None, # setting the cijk from Mestre's algorithm c111 = 12*x*y - 2*y/3 - 4*z c112 = -18*x**3 - 12*x*y - 36*y**2 - 2*z - c113 = -9*x**3 - 36*x**2*y -4*x*y - 6*x*z - 18*y**2 + c113 = -9*x**3 - 36*x**2*y - 4*x*y - 6*x*z - 18*y**2 c122 = c113 c123 = -54*x**4 - 36*x**2*y - 36*x*y**2 - 6*x*z - 4*y**2 - 24*y*z c133 = -27*x**4/2 - 72*x**3*y - 6*x**2*y - 9*x**2*z - 39*x*y**2 - \ diff --git a/src/sage/schemes/jacobians/abstract_jacobian.py b/src/sage/schemes/jacobians/abstract_jacobian.py index 08bee459739..31b81bf214b 100644 --- a/src/sage/schemes/jacobians/abstract_jacobian.py +++ b/src/sage/schemes/jacobians/abstract_jacobian.py @@ -122,11 +122,11 @@ def __init__(self, C): defined by x + y + z) must be defined over a field. """ if not is_Scheme(C): - raise TypeError("Argument (=%s) must be a scheme."%C) + raise TypeError("Argument (=%s) must be a scheme." % C) if C.base_ring() not in _Fields: - raise TypeError("C (=%s) must be defined over a field."%C) + raise TypeError("C (=%s) must be defined over a field." % C) if C.dimension() != 1: - raise ValueError("C (=%s) must have dimension 1."%C) + raise ValueError("C (=%s) must have dimension 1." % C) self.__curve = C Scheme.__init__(self, C.base_scheme()) diff --git a/src/sage/schemes/plane_conics/con_field.py b/src/sage/schemes/plane_conics/con_field.py index fa813565f7a..3a3d0aa3a2a 100644 --- a/src/sage/schemes/plane_conics/con_field.py +++ b/src/sage/schemes/plane_conics/con_field.py @@ -284,7 +284,7 @@ def diagonal_matrix(self): B = self.base_ring() basis = [vector(B,{2:0,i:1}) for i in range(3)] for i in range(3): - zerovalue = (basis[i]*A*basis[i].column()== 0) + zerovalue = (basis[i]*A*basis[i].column() == 0) if zerovalue: for j in range(i+1,3): if basis[j]*A*basis[j].column() != 0: diff --git a/src/sage/schemes/product_projective/homset.py b/src/sage/schemes/product_projective/homset.py index 91af8105def..61e23e848ec 100644 --- a/src/sage/schemes/product_projective/homset.py +++ b/src/sage/schemes/product_projective/homset.py @@ -201,7 +201,7 @@ def points(self, **kwds): points = [] if is_RationalField(R): if not B > 0: - raise TypeError("a positive bound B (= %s) must be specified"%B) + raise TypeError("a positive bound B (= %s) must be specified" % B) alg = kwds.pop('algorithm', None) if alg is None: # sieve should only be called for subschemes and if the bound is not very small @@ -222,7 +222,7 @@ def points(self, **kwds): raise ValueError("algorithm must be 'sieve' or 'enumerate'") elif R in NumberFields(): if not B > 0: - raise TypeError("a positive bound B (= %s) must be specified"%B) + raise TypeError("a positive bound B (= %s) must be specified" % B) from sage.schemes.product_projective.rational_point import enum_product_projective_number_field return enum_product_projective_number_field(self, bound=B) elif isinstance(R, FiniteField): diff --git a/src/sage/schemes/product_projective/morphism.py b/src/sage/schemes/product_projective/morphism.py index f28aa84e7ba..5cf9338606b 100644 --- a/src/sage/schemes/product_projective/morphism.py +++ b/src/sage/schemes/product_projective/morphism.py @@ -115,7 +115,7 @@ def __init__(self, parent, polys, check=True): for m in range(len(splitpolys)): d = dom._degree(splitpolys[m][0]) if not all(d == dom._degree(f) for f in splitpolys[m]): - raise TypeError("polys (=%s) must be multi-homogeneous of the same degrees (by component)"%polys) + raise TypeError("polys (=%s) must be multi-homogeneous of the same degrees (by component)" % polys) else: #we are mapping into some other kind of space target._validate(polys) @@ -225,9 +225,9 @@ def __call__(self, P, check=True): try: P = self.domain()(P) except (TypeError, NotImplementedError): - raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(P, self.domain())) - elif self.domain()!= P.codomain(): - raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(P, self.domain())) + raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented" % (P, self.domain())) + elif self.domain() != P.codomain(): + raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented" % (P, self.domain())) A = self.codomain() Q = list(P) diff --git a/src/sage/schemes/product_projective/point.py b/src/sage/schemes/product_projective/point.py index 09cd0225209..1823698c330 100644 --- a/src/sage/schemes/product_projective/point.py +++ b/src/sage/schemes/product_projective/point.py @@ -99,7 +99,7 @@ def __init__(self, parent, polys, check=True): N = parent.codomain().ambient_space().dimension_relative_components() if check: parent.codomain()._check_satisfies_equations(polys) - splitpolys=self.codomain().ambient_space()._factors(polys) + splitpolys = self.codomain().ambient_space()._factors(polys) self._points = [parent.codomain().ambient_space()[i].point(splitpolys[i], check) for i in range(len(N))] def __getitem__(self, i): diff --git a/src/sage/schemes/product_projective/space.py b/src/sage/schemes/product_projective/space.py index c17524ed163..ecdec43b7ca 100644 --- a/src/sage/schemes/product_projective/space.py +++ b/src/sage/schemes/product_projective/space.py @@ -243,7 +243,7 @@ def __init__(self, N, R=QQ, names=None): # Note that the coordinate ring should really be the tensor product of # the component coordinate rings. But we just deal with them as # multihomogeneous polynomial rings. - self._coordinate_ring = PolynomialRing(R,sum(N)+ len(N),names) + self._coordinate_ring = PolynomialRing(R,sum(N) + len(N),names) self._assign_names(names) def _repr_(self): @@ -604,12 +604,12 @@ def _factors(self, v): [[1, 2], [3, 4], [5, 6]] """ if not isinstance(v, (list, tuple, ETuple)): - raise TypeError("%s, must be a list or tuple"%v) + raise TypeError("%s, must be a list or tuple" % v) if len(v) != self.ngens(): - raise ValueError("%s must have %s elements"%(v, self.ngens())) + raise ValueError("%s must have %s elements" % (v, self.ngens())) index = 0 splitv = [] - dims=self._dims + dims = self._dims for i in range(len(dims)): splitv.append(v[index:index+dims[i]+1]) index += dims[i]+1 @@ -731,13 +731,13 @@ def _validate(self, polynomials): Polynomial Ring in x, y, z, w, u over Rational Field """ if not isinstance(polynomials, (list, tuple)): - raise TypeError('the argument polynomials=%s must be a list or tuple'%polynomials) + raise TypeError('the argument polynomials=%s must be a list or tuple' % polynomials) #check in the coordinate ring source_ring = self.coordinate_ring() try: polynomials = [source_ring(poly) for poly in polynomials] except TypeError: - raise TypeError("polynomials (=%s) must be elements of %s"%(polynomials,source_ring)) + raise TypeError("polynomials (=%s) must be elements of %s" % (polynomials,source_ring)) for f in polynomials: self._degree(f) #raises a ValueError if not multi-homogeneous return polynomials @@ -785,15 +785,15 @@ def _check_satisfies_equations(self, v): TypeError: the components of v=[1, 1/2, 1, 0] must be elements of Integer Ring """ if not isinstance(v, (list, tuple)): - raise TypeError('the argument v=%s must be a list or tuple'%v) + raise TypeError('the argument v=%s must be a list or tuple' % v) n = self.ngens() if not len(v) == n: - raise TypeError('the list v=%s must have %s components'%(v, n)) + raise TypeError('the list v=%s must have %s components' % (v, n)) R = self.base_ring() try: n = [R(w) for w in v] except TypeError: - raise TypeError('the components of v=%s must be elements of %s'%(v, R)) + raise TypeError('the components of v=%s must be elements of %s' % (v, R)) #check if any of the component points are 0 N = self._dims start = 0 @@ -921,15 +921,15 @@ def affine_patch(self, I, return_embedding=False): (1 : x0 : x1 , x2 : 1 : x3 , x4 : x5 : 1) """ if not isinstance(I, (list, tuple)): - raise TypeError('the argument I=%s must be a list or tuple of positive integers'%I) + raise TypeError('the argument I=%s must be a list or tuple of positive integers' % I) PP = self.ambient_space() N = PP._dims if len(I) != len(N): - raise ValueError('the argument I=%s must have %s entries'%(I,len(N))) + raise ValueError('the argument I=%s must have %s entries' % (I,len(N))) I = tuple([int(i) for i in I]) # implicit type checking for i in range(len(I)): if I[i] < 0 or I[i] > N[i]: - raise ValueError("argument i (= %s) must be between 0 and %s."%(I[i], N[i])) + raise ValueError("argument i (= %s) must be between 0 and %s." % (I[i], N[i])) try: if return_embedding: return self.__affine_patches[I][1] @@ -1057,7 +1057,7 @@ def segre_embedding(self, PP=None, var='u'): Y = PS.subscheme(L) else: if PP.dimension_relative() != M: - raise ValueError("projective Space %s must be dimension %s")%(PP, M) + raise ValueError("projective Space %s must be dimension %s") % (PP, M) S = PP.coordinate_ring() psi = R.hom([0]*k + list(S.gens()), S) L = [psi(l) for l in L] @@ -1294,5 +1294,5 @@ def rational_points(self, F=None): if F is None: return list(self) elif not isinstance(F, FiniteField): - raise TypeError("second argument (= %s) must be a finite field"%F) + raise TypeError("second argument (= %s) must be a finite field" % F) return list(self.base_extend(F)) diff --git a/src/sage/schemes/product_projective/subscheme.py b/src/sage/schemes/product_projective/subscheme.py index 1678ab2f472..9d96f0eb2d3 100644 --- a/src/sage/schemes/product_projective/subscheme.py +++ b/src/sage/schemes/product_projective/subscheme.py @@ -161,7 +161,7 @@ def segre_embedding(self, PP=None): Y = PS.subscheme(L) else: if PP.dimension_relative() != M: - raise ValueError("projective space %s must be dimension %s")%(PP, M) + raise ValueError("projective space %s must be dimension %s") % (PP, M) S = PP.coordinate_ring() psi = R.hom([0]*k + list(S.gens()), S) L = [psi(l) for l in L] @@ -300,11 +300,11 @@ def affine_patch(self, I, return_embedding=False): PP = self.ambient_space() N = PP.dimension_relative_components() if len(I) != len(N): - raise ValueError('The argument I=%s must have %s entries'%(I,len(N))) + raise ValueError('The argument I=%s must have %s entries' % (I,len(N))) I = tuple([int(i) for i in I]) # implicit type checking for i in range(len(I)): if I[i] < 0 or I[i] > N[i]: - raise ValueError("Argument i (= %s) must be between 0 and %s."%(I[i], N[i])) + raise ValueError("Argument i (= %s) must be between 0 and %s." % (I[i], N[i])) #see if we've already created this affine patch try: if return_embedding: @@ -388,7 +388,7 @@ def intersection_multiplicity(self, X, P): try: PP(P) except TypeError: - raise TypeError("(=%s) must be a point in the ambient space of this subscheme and (=%s)"%(P,X)) + raise TypeError("(=%s) must be a point in the ambient space of this subscheme and (=%s)" % (P,X)) # find an affine chart of the ambient space of this subscheme that contains P indices = [] aff_pt = [] diff --git a/src/sage/schemes/projective/projective_homset.py b/src/sage/schemes/projective/projective_homset.py index c4aa79b9f7a..0825408195f 100644 --- a/src/sage/schemes/projective/projective_homset.py +++ b/src/sage/schemes/projective/projective_homset.py @@ -274,7 +274,7 @@ def points(self, **kwds): prec = kwds.pop('precision', 53) if is_RationalField(R): if not B > 0: - raise TypeError("a positive bound B (= %s) must be specified"%B) + raise TypeError("a positive bound B (= %s) must be specified" % B) if isinstance(X, AlgebraicScheme_subscheme): # sieve should only be called for subschemes from sage.schemes.projective.projective_rational_point import sieve return sieve(X, B) @@ -283,14 +283,14 @@ def points(self, **kwds): return enum_projective_rational_field(self, B) elif R in NumberFields(): if not B > 0: - raise TypeError("a positive bound B (= %s) must be specified"%B) + raise TypeError("a positive bound B (= %s) must be specified" % B) from sage.schemes.projective.projective_rational_point import enum_projective_number_field return enum_projective_number_field(self, bound=B, tolerance=tol, precision=prec) elif isinstance(R, FiniteField): from sage.schemes.projective.projective_rational_point import enum_projective_finite_field return enum_projective_finite_field(self.extended_codomain()) else: - raise TypeError("unable to enumerate points over %s"%R) + raise TypeError("unable to enumerate points over %s" % R) def numerical_points(self, F=None, **kwds): """ @@ -424,7 +424,7 @@ def numerical_points(self, F=None, **kwds): #of coordinates known so far. This results in a single #variable polynomial (by elimination) L = G[i].substitute(P) - if len(RF(L).variables())==1: + if len(RF(L).variables()) == 1: for pol in L.univariate_polynomial().roots(ring=F, multiplicities=False): r = L.variables()[0] varindex = RF.gens().index(r) @@ -523,11 +523,11 @@ def points(self, B=0): R = self.value_ring() if R == ZZ: if not B > 0: - raise TypeError("a positive bound B (= %s) must be specified"%B) + raise TypeError("a positive bound B (= %s) must be specified" % B) from sage.schemes.projective.projective_rational_point import enum_projective_rational_field return enum_projective_rational_field(self,B) else: - raise TypeError("unable to enumerate points over %s"%R) + raise TypeError("unable to enumerate points over %s" % R) class SchemeHomset_polynomial_projective_space(SchemeHomset_generic): diff --git a/src/sage/schemes/projective/projective_point.py b/src/sage/schemes/projective/projective_point.py index 05675ce2cc6..328754bfb90 100644 --- a/src/sage/schemes/projective/projective_point.py +++ b/src/sage/schemes/projective/projective_point.py @@ -177,9 +177,9 @@ def __init__(self, X, v, check=True): except AttributeError: pass if not isinstance(v, (list, tuple)): - raise TypeError("argument v (= %s) must be a scheme point, list, or tuple"%str(v)) + raise TypeError("argument v (= %s) must be a scheme point, list, or tuple" % str(v)) if len(v) != d and len(v) != d-1: - raise TypeError("v (=%s) must have %s components"%(v, d)) + raise TypeError("v (=%s) must have %s components" % (v, d)) R = X.value_ring() v = Sequence(v, R) @@ -1137,9 +1137,9 @@ def __init__(self, X, v, check=True): except AttributeError: pass if not isinstance(v, (list,tuple)): - raise TypeError("argument v (= %s) must be a scheme point, list, or tuple"%str(v)) + raise TypeError("argument v (= %s) must be a scheme point, list, or tuple" % str(v)) if len(v) != d and len(v) != d-1: - raise TypeError("v (=%s) must have %s components"%(v, d)) + raise TypeError("v (=%s) must have %s components" % (v, d)) R = X.value_ring() v = Sequence(v, R) diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py index c247f630ff6..7755897396a 100644 --- a/src/sage/schemes/projective/projective_subscheme.py +++ b/src/sage/schemes/projective/projective_subscheme.py @@ -113,7 +113,7 @@ def point(self, v, check=True): if v is infinity or\ (isinstance(v, (list,tuple)) and len(v) == 1 and v[0] is infinity): if self.ambient_space().dimension_relative() > 1: - raise ValueError("%s not well defined in dimension > 1"%v) + raise ValueError("%s not well defined in dimension > 1" % v) v = [1, 0] # todo: update elliptic curve stuff to take point_homset as argument from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve @@ -259,7 +259,7 @@ def affine_patch(self, i, AA=None): PP = self.ambient_space() n = PP.dimension_relative() if i < 0 or i > n: - raise ValueError("Argument i (= %s) must be between 0 and %s."%(i, n)) + raise ValueError("Argument i (= %s) must be between 0 and %s." % (i, n)) try: A = self.__affine_patches[i] #assume that if you've passed in a new ambient affine space @@ -273,7 +273,7 @@ def affine_patch(self, i, AA=None): if AA is None: AA = PP.affine_patch(i) elif AA.dimension_relative() != n: - raise ValueError("Affine Space must be of the dimension %s"%(n)) + raise ValueError("Affine Space must be of the dimension %s" % (n)) phi = AA.projective_embedding(i, PP) polys = self.defining_polynomials() xi = phi.defining_polynomials() @@ -325,7 +325,7 @@ def _best_affine_patch(self, point): i_max = 0 p_max = abs_point[i_max] for i in range(1,len(point)): - if abs_point[i]>p_max: + if abs_point[i] > p_max: i_max = i p_max = abs_point[i_max] return i_max @@ -1098,7 +1098,7 @@ def intersection_multiplicity(self, X, P): try: self.ambient_space()(P) except TypeError: - raise TypeError("(=%s) must be a point in the ambient space of this subscheme and (=%s)"%(P,X)) + raise TypeError("(=%s) must be a point in the ambient space of this subscheme and (=%s)" % (P,X)) # find an affine chart of the ambient space of this curve that contains P n = self.ambient_space().dimension_relative() for i in range(n + 1): @@ -1393,7 +1393,7 @@ def Chow_form(self): # polynomial ring in just the plucker coordinates T2 = PolynomialRing(R.base_ring(), tvars) - alp = T.hom(tvars + (N*(d+1) +N)*[0], T2) + alp = T.hom(tvars + (N*(d+1) + N)*[0], T2) # get the degrees of the reduced generators of CH degs = [u.degree() for u in reduced] mind = max(degs)