Skip to content

Commit

Permalink
fix E228 and E225 in schemes/
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Sep 4, 2023
1 parent 6ea1fe9 commit f495b38
Show file tree
Hide file tree
Showing 25 changed files with 131 additions and 131 deletions.
8 changes: 4 additions & 4 deletions src/sage/schemes/elliptic_curves/ell_rational_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/sage/schemes/elliptic_curves/padics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
30 changes: 15 additions & 15 deletions src/sage/schemes/generic/algebraic_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)

Check warning on line 875 in src/sage/schemes/generic/algebraic_scheme.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/algebraic_scheme.py#L875

Added line #L875 was not covered by tests
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)

Check warning on line 877 in src/sage/schemes/generic/algebraic_scheme.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/algebraic_scheme.py#L877

Added line #L877 was not covered by tests
pts = []
for P in self.ambient_space().rational_points(F):
try:
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)

Check warning on line 1468 in src/sage/schemes/generic/algebraic_scheme.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/algebraic_scheme.py#L1468

Added line #L1468 was not covered by tests
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)

Check warning on line 1471 in src/sage/schemes/generic/algebraic_scheme.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/algebraic_scheme.py#L1471

Added line #L1471 was not covered by tests
return A.subscheme(self.defining_ideal().intersection(other.defining_ideal()))

def __pow__(self, m):
Expand Down Expand Up @@ -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)

Check warning on line 1652 in src/sage/schemes/generic/algebraic_scheme.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/algebraic_scheme.py#L1652

Added line #L1652 was not covered by tests
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)

Check warning on line 1655 in src/sage/schemes/generic/algebraic_scheme.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/algebraic_scheme.py#L1655

Added line #L1655 was not covered by tests
return A.subscheme(self.defining_ideal() + other.defining_ideal())

def complement(self, other=None):
Expand Down Expand Up @@ -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)

Check warning on line 1711 in src/sage/schemes/generic/algebraic_scheme.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/algebraic_scheme.py#L1711

Added line #L1711 was not covered by tests
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)

Check warning on line 1713 in src/sage/schemes/generic/algebraic_scheme.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/algebraic_scheme.py#L1713

Added line #L1713 was not covered by tests
return AlgebraicScheme_quasi(other, self)

def rational_points(self, **kwds):
Expand Down Expand Up @@ -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)

Check warning on line 1834 in src/sage/schemes/generic/algebraic_scheme.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/algebraic_scheme.py#L1834

Added line #L1834 was not covered by tests
elif (self.base_ring() in NumberFields() or self.base_ring() == ZZ)\
and hasattr(F, 'precision'):
#we are numerically approximating number field points
Expand All @@ -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)

Check warning on line 1843 in src/sage/schemes/generic/algebraic_scheme.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/algebraic_scheme.py#L1843

Added line #L1843 was not covered by tests

def change_ring(self, R):
r"""
Expand Down
8 changes: 4 additions & 4 deletions src/sage/schemes/generic/glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ 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)

Check warning on line 36 in src/sage/schemes/generic/glue.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/glue.py#L36

Added line #L36 was not covered by tests
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)

Check warning on line 38 in src/sage/schemes/generic/glue.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/glue.py#L38

Added line #L38 was not covered by tests
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))

Check warning on line 40 in src/sage/schemes/generic/glue.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/glue.py#L40

Added line #L40 was not covered by tests
self.__f = f
self.__g = g

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())
10 changes: 5 additions & 5 deletions src/sage/schemes/generic/hypersurface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 97 in src/sage/schemes/generic/hypersurface.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/hypersurface.py#L97

Added line #L97 was not covered by tests
if not poly.is_homogeneous():
raise TypeError("Defining polynomial (=%s) must be homogeneous."%poly)
raise TypeError("Defining polynomial (=%s) must be homogeneous." % poly)

Check warning on line 99 in src/sage/schemes/generic/hypersurface.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/hypersurface.py#L99

Added line #L99 was not covered by tests
if ambient is None:
R = poly.parent()
from sage.schemes.projective.projective_space import ProjectiveSpace
Expand All @@ -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):
Expand Down Expand Up @@ -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)

Check warning on line 187 in src/sage/schemes/generic/hypersurface.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/hypersurface.py#L187

Added line #L187 was not covered by tests
if ambient is None:
R = poly.parent()
from sage.schemes.affine.affine_space import AffineSpace
Expand All @@ -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):
Expand Down
30 changes: 15 additions & 15 deletions src/sage/schemes/generic/morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 168 in src/sage/schemes/generic/morphism.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/morphism.py#L168

Added line #L168 was not covered by tests
Element.__init__(self, parent)
self._codomain = parent.codomain()

Expand Down Expand Up @@ -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()))

Check warning on line 264 in src/sage/schemes/generic/morphism.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/morphism.py#L264

Added line #L264 was not covered by tests
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()))

Check warning on line 266 in src/sage/schemes/generic/morphism.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/morphism.py#L266

Added line #L266 was not covered by tests
else:
x = converter(x)
if not args and not kwds:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Check warning on line 998 in src/sage/schemes/generic/morphism.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/morphism.py#L998

Added line #L998 was not covered by tests
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())

Check warning on line 1002 in src/sage/schemes/generic/morphism.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/morphism.py#L1002

Added line #L1002 was not covered by tests
F = []
for poly in polys:
try:
Expand All @@ -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)

Expand Down Expand Up @@ -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):
"""
Expand Down
8 changes: 4 additions & 4 deletions src/sage/schemes/generic/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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):
Expand Down Expand Up @@ -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(),

Check warning on line 250 in src/sage/schemes/generic/point.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/generic/point.py#L250

Added line #L250 was not covered by tests
self.morphism())

def morphism(self):
Expand Down
Loading

0 comments on commit f495b38

Please sign in to comment.