Skip to content

Commit

Permalink
gh-36191: fix E228 and E225 in schemes/
Browse files Browse the repository at this point in the history
    
fix pycodestyle warnings E228 and E225 in schemes

this was done using `autopep8`

### 📝 Checklist

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
    
URL: #36191
Reported by: Frédéric Chapoton
Reviewer(s): Kwankyu Lee
  • Loading branch information
Release Manager committed Sep 10, 2023
2 parents 7b8b6b6 + f495b38 commit 66aacc5
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 @@ -527,7 +527,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 @@ -819,11 +819,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 @@ -870,9 +870,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:
Expand Down Expand Up @@ -984,11 +984,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 @@ -1463,10 +1463,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):
Expand Down Expand Up @@ -1647,10 +1647,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):
Expand Down Expand Up @@ -1706,9 +1706,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):
Expand Down Expand Up @@ -1832,7 +1832,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
Expand All @@ -1841,7 +1841,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"""
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)
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

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 @@ -95,9 +95,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
Expand All @@ -120,7 +120,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 @@ -185,7 +185,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
Expand All @@ -208,7 +208,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)
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()))
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:
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 @@ -996,11 +996,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:
Expand All @@ -1012,7 +1012,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 @@ -1245,7 +1245,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(),
self.morphism())

def morphism(self):
Expand Down
Loading

0 comments on commit 66aacc5

Please sign in to comment.