Skip to content

Commit

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

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: #36192
Reported by: Frédéric Chapoton
Reviewer(s): Frédéric Chapoton, Kwankyu Lee
  • Loading branch information
Release Manager committed Sep 10, 2023
2 parents 66aacc5 + 39dfddd commit 15a0566
Show file tree
Hide file tree
Showing 58 changed files with 303 additions and 302 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ def univariate_decomposition(self):
for a, m in df:
am = a**m
q, r = denominator.quo_rem(am)
assert r==0
assert r == 0
numer = p * q.inverse_mod(am) % am
# The inverse exists because the product and a**m
# are relatively prime.
Expand Down Expand Up @@ -1930,7 +1930,7 @@ def asymptotics_smooth(self, p, alpha, N, asy_var, coordinate=None,
if v.mod(2) == 0:
At_derivs = diff_all(At, T, 2 * N - 2, sub=hderivs1,
sub_final=[Tstar, atP], rekey=AA)
Phitu_derivs = diff_all(Phitu, T, 2 * N - 2 +v,
Phitu_derivs = diff_all(Phitu, T, 2 * N - 2 + v,
sub=hderivs1, sub_final=[Tstar, atP],
zero_order=v + 1, rekey=BB)
else:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/complex_interval_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def _repr_(self):
sage: ComplexIntervalField(100) # indirect doctest
Complex Interval Field with 100 bits of precision
"""
return "Complex Interval Field with %s bits of precision"%self._prec
return "Complex Interval Field with %s bits of precision" % self._prec

def _latex_(self):
r"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/finite_rings/conway_polynomials.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def find_leveller(qindex, level, x, xleveled, searched, i):
searched[i] = True
crt_possibles = []
for j in range(1,len(qlist)):
if i==j:
if i == j:
continue
if crt[(i,j)][qindex][1] >= level:
if xleveled[j]:
Expand All @@ -487,7 +487,7 @@ def find_leveller(qindex, level, x, xleveled, searched, i):

def propagate_levelling(qindex, level, x, xleveled, i):
for j in range(1, len(qlist)):
if i==j:
if i == j:
continue
if not xleveled[j] and crt[(i,j)][qindex][1] >= level:
newxj = x[i][0] + crt[(i,j)][qindex][0]
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/finite_rings/finite_field_givaro.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def _pari_modulus(self):
Mod(1, 3)*a^4 + Mod(2, 3)*a^3 + Mod(2, 3)
"""
f = pari(str(self.modulus()))
return f.subst('x', 'a') * pari("Mod(1,%s)"%self.characteristic())
return f.subst('x', 'a') * pari("Mod(1,%s)" % self.characteristic())

def __iter__(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/finite_rings/finite_field_ntl_gf2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,4 @@ def _pari_modulus(self):
Mod(1, 2)*a^16 + Mod(1, 2)*a^5 + Mod(1, 2)*a^3 + Mod(1, 2)*a^2 + Mod(1, 2)
"""
f = pari(str(self.modulus()))
return f.subst('x', 'a') * pari("Mod(1,%s)"%self.characteristic())
return f.subst('x', 'a') * pari("Mod(1,%s)" % self.characteristic())
4 changes: 2 additions & 2 deletions src/sage/rings/finite_rings/homset.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ def _repr_(self):
D = self.domain()
C = self.codomain()
if C == D:
return "Automorphism group of %s"%D
return "Automorphism group of %s" % D
else:
return "Set of field embeddings from %s to %s"%(D, C)
return "Set of field embeddings from %s to %s" % (D, C)

def is_aut(self):
"""
Expand Down
8 changes: 4 additions & 4 deletions src/sage/rings/function_field/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def create_key(self, F, names):
sage: K.<x> = FunctionField(QQ) # indirect doctest
"""
if not isinstance(names, tuple):
names=(names,)
names = (names,)
return (F, names)

def create_object(self, version, key,**extra_args):
Expand All @@ -112,7 +112,7 @@ def create_object(self, version, key,**extra_args):
return RationalFunctionField(key[0], names=key[1])


FunctionField=FunctionFieldFactory("sage.rings.function_field.constructor.FunctionField")
FunctionField = FunctionFieldFactory("sage.rings.function_field.constructor.FunctionField")


class FunctionFieldExtensionFactory(UniqueFactory):
Expand Down Expand Up @@ -171,9 +171,9 @@ def create_key(self,polynomial,names):
"""
if names is None:
names=polynomial.variable_name()
names = polynomial.variable_name()
if not isinstance(names,tuple):
names=(names,)
names = (names,)
return (polynomial,names,polynomial.base_ring())

def create_object(self,version,key,**extra_args):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/divisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ def _repr_(self):
sage: F.divisor_group()
Divisor group of Function field in y defined by y^2 + 4*x^3 + 4
"""
return "Divisor group of %s"%(self._field,)
return "Divisor group of %s" % (self._field,)

def _element_constructor_(self, x):
"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/function_field/function_field_polymod.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def _to_base_field(self, f):
K = self.base_field()
if f.element().is_constant():
return K(f.element())
raise ValueError("%r is not an element of the base field"%(f,))
raise ValueError("%r is not an element of the base field" % (f,))

def _to_constant_base_field(self, f):
"""
Expand Down Expand Up @@ -572,7 +572,7 @@ def _repr_(self):
sage: L._repr_()
'Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x'
"""
return "Function field in %s defined by %s"%(self.variable_name(), self._polynomial)
return "Function field in %s defined by %s" % (self.variable_name(), self._polynomial)

def base_field(self):
"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/rings/function_field/function_field_rational.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def _repr_(self):
sage: K._repr_()
'Rational function field in t over Rational Field'
"""
return "Rational function field in %s over %s"%(
return "Rational function field in %s over %s" % (
self.variable_name(), self._constant_field)

def _element_constructor_(self, x):
Expand Down Expand Up @@ -304,7 +304,7 @@ def _to_constant_base_field(self, f):
# When K is not exact, f.denominator() might not be an exact 1, so
# we need to divide explicitly to get the correct precision
return K(f.numerator()) / K(f.denominator())
raise ValueError("only constants can be converted into the constant base field but %r is not a constant"%(f,))
raise ValueError("only constants can be converted into the constant base field but %r is not a constant" % (f,))

def _to_polynomial(self, f):
"""
Expand Down Expand Up @@ -349,7 +349,7 @@ def _to_bivariate_polynomial(self, f):
v = f.list()
denom = lcm([a.denominator() for a in v])
S = denom.parent()
x,t = S.base_ring()['%s,%s'%(f.parent().variable_name(),self.variable_name())].gens()
x,t = S.base_ring()['%s,%s' % (f.parent().variable_name(),self.variable_name())].gens()
phi = S.hom([t])
return sum([phi((denom * v[i]).numerator()) * x**i for i in range(len(v))]), denom

Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/function_field/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def _repr_(self):
sage: FunctionField(QQ,'y').maximal_order()._repr_()
'Maximal order of Rational function field in y over Rational Field'
"""
return "Maximal order of %s"%(self.function_field(),)
return "Maximal order of %s" % (self.function_field(),)


class FunctionFieldMaximalOrderInfinite(FunctionFieldMaximalOrder, FunctionFieldOrderInfinite):
Expand All @@ -278,4 +278,4 @@ def _repr_(self):
sage: F.maximal_order_infinite() # needs sage.modules sage.rings.function_field
Maximal infinite order of Function field in y defined by y^3 + x^6 + x^4 + x^2
"""
return "Maximal infinite order of %s"%(self.function_field(),)
return "Maximal infinite order of %s" % (self.function_field(),)
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/order_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self, basis, check=True):
R = V.base_field().maximal_order()
self._module = V.span([to_V(b) for b in basis], base_ring=R)

self._from_module= from_V
self._from_module = from_V
self._to_module = to_V
self._basis = tuple(basis)
self._ring = field.polynomial_ring()
Expand Down
10 changes: 5 additions & 5 deletions src/sage/rings/function_field/order_polymod.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def decomposition(self, ideal):
# occurs by constructing a matrix in k, and finding a non-zero
# vector in the kernel of the matrix.

m =[]
m = []
for g in q.basis_matrix():
m.extend(matrix([g * mr for mr in matrices_reduced]).columns())
beta = [c.lift() for c in matrix(m).right_kernel().basis()[0]]
Expand Down Expand Up @@ -784,7 +784,7 @@ def _element_constructor_(self, f):
O = F.base_field().maximal_order_infinite()
coordinates = self.coordinate_vector(f)
if not all(c in O for c in coordinates):
raise TypeError("%r is not an element of %r"%(f,self))
raise TypeError("%r is not an element of %r" % (f,self))

return f

Expand Down Expand Up @@ -1288,7 +1288,7 @@ def decomposition(self, ideal):

# p and qgen generates the prime; modulo pO, qgenb generates the prime
qgenb = [to(qgen[i]) for i in range(n)]
m =[]
m = []
for i in range(n):
m.append(sum(qgenb[j] * mtable[i][j] for j in range(n)))
beta = [fr(coeff) for coeff in matrix(m).left_kernel().basis()[0]]
Expand Down Expand Up @@ -1383,7 +1383,7 @@ def add(Ib,Jb):
Kb.append(Lb)

# J_1, J_2, ...
Jb =[Kb[0]] + [div(Kb[j],Kb[j-1]) for j in range(1,len(Kb))]
Jb = [Kb[0]] + [div(Kb[j],Kb[j-1]) for j in range(1,len(Kb))]

# H_1, H_2, ...
Hb = [div(Jb[j],Jb[j+1]) for j in range(len(Jb)-1)] + [Jb[-1]]
Expand Down Expand Up @@ -1455,7 +1455,7 @@ def split(h):
# Compute an element beta in O but not in pO. How to find beta
# is explained in Section 4.8.3 of [Coh1993]. We keep beta
# as a vector over k[x] with respect to the basis of O.
m =[]
m = []
for i in range(n):
r = []
for g in prime._hnf:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/order_rational.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _element_constructor_(self, f):
raise TypeError("unable to convert to an element of {}".format(F))

if not f.denominator() in self.function_field().constant_base_field():
raise TypeError("%r is not an element of %r"%(f,self))
raise TypeError("%r is not an element of %r" % (f,self))

return f

Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/place_polymod.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ def candidates():
if deg > 1:
if isinstance(k, NumberField):
if name is None:
name='s'
name = 's'
K = k.extension(min_poly, names=name)

def from_W(e):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/place_rational.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def to_K(f):
d = f.denominator()

n_deg = n.degree()
d_deg =d.degree()
d_deg = d.degree()

if n_deg < d_deg:
return K(0)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/homset.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _repr_(self):
sage: Hom(ZZ, QQ) # indirect doctest
Set of Homomorphisms from Integer Ring to Rational Field
"""
return "Set of Homomorphisms from %s to %s"%(self.domain(), self.codomain())
return "Set of Homomorphisms from %s to %s" % (self.domain(), self.codomain())

def has_coerce_map_from(self, x):
"""
Expand Down Expand Up @@ -212,7 +212,7 @@ def natural_map(self):
"""
f = self.codomain().coerce_map_from(self.domain())
if f is None:
raise TypeError("natural coercion morphism from %s to %s not defined"%(self.domain(), self.codomain()))
raise TypeError("natural coercion morphism from %s to %s not defined" % (self.domain(), self.codomain()))
return f

def zero(self):
Expand Down
12 changes: 6 additions & 6 deletions src/sage/rings/ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ def _repr_short(self):
s = s.replace('\n','\n ')
L.append(s)
if has_return:
return '\n(\n %s\n)\n'%(',\n\n '.join(L))
return '(%s)'%(', '.join(L))
return '\n(\n %s\n)\n' % (',\n\n '.join(L))
return '(%s)' % (', '.join(L))

def __repr__(self):
"""
Expand All @@ -329,7 +329,7 @@ def __repr__(self):
sage: P*[a^2,a*b+c,c^3] # indirect doctest
Ideal (a^2, a*b + c, c^3) of Multivariate Polynomial Ring in a, b, c over Rational Field
"""
return "Ideal %s of %s"%(self._repr_short(), self.ring())
return "Ideal %s of %s" % (self._repr_short(), self.ring())

def random_element(self, *args, **kwds):
"""
Expand Down Expand Up @@ -1280,7 +1280,7 @@ def __repr__(self):
sage: I # indirect doctest
Principal ideal (x) of Univariate Polynomial Ring in x over Integer Ring
"""
return "Principal ideal (%s) of %s"%(self.gen(), self.ring())
return "Principal ideal (%s) of %s" % (self.gen(), self.ring())

def is_principal(self):
r"""
Expand Down Expand Up @@ -1693,7 +1693,7 @@ def residue_field(self):
TypeError: residue fields only supported for polynomial rings over finite fields.
"""
if not self.is_prime():
raise ValueError("The ideal (%s) is not prime"%self)
raise ValueError("The ideal (%s) is not prime" % self)
from sage.rings.integer_ring import ZZ
if self.ring() is ZZ:
return ZZ.residue_field(self, check=False)
Expand All @@ -1717,7 +1717,7 @@ def __repr__(self):
sage: Ideal_fractional(K, [a]) # indirect doctest # needs sage.rings.number_field
Fractional ideal (a) of Number Field in a with defining polynomial x^2 + 1
"""
return "Fractional ideal %s of %s"%(self._repr_short(), self.ring())
return "Fractional ideal %s of %s" % (self._repr_short(), self.ring())

# constructors for standard (benchmark) ideals, written uppercase as
# these are constructors
Expand Down
Loading

0 comments on commit 15a0566

Please sign in to comment.