diff --git a/src/sage/rings/function_field/function_field_polymod.py b/src/sage/rings/function_field/function_field_polymod.py index b740b771bec..44c1390bc86 100644 --- a/src/sage/rings/function_field/function_field_polymod.py +++ b/src/sage/rings/function_field/function_field_polymod.py @@ -418,10 +418,11 @@ def monic_integral_model(self, names=None): raise ValueError("names must contain at most 2 entries") if self.base_field() is not self.rational_function_field(): - L,from_L,to_L = self.simple_model() - ret,ret_to_L,L_to_ret = L.monic_integral_model(names) - from_ret = ret.hom( [from_L(ret_to_L(ret.gen())), from_L(ret_to_L(ret.base_field().gen()))] ) - to_ret = self.hom( [L_to_ret(to_L(k.gen())) for k in self._intermediate_fields(self.rational_function_field())] ) + L, from_L, to_L = self.simple_model() + ret, ret_to_L, L_to_ret = L.monic_integral_model(names) + from_ret = ret.hom([from_L(ret_to_L(ret.gen())), + from_L(ret_to_L(ret.base_field().gen()))]) + to_ret = self.hom([L_to_ret(to_L(k.gen())) for k in self._intermediate_fields(self.rational_function_field())]) return ret, from_ret, to_ret else: if self.polynomial().is_monic() and all(c.denominator().is_one() for c in self.polynomial()): @@ -431,12 +432,12 @@ def monic_integral_model(self, names=None): return self.change_variable_name(names) else: if not names: - names = (self.variable_name()+"_",) + names = (self.variable_name() + "_",) if len(names) == 1: names = (names[0], self.rational_function_field().variable_name()) g, d = self._make_monic_integral(self.polynomial()) - K,from_K,to_K = self.base_field().change_variable_name(names[1]) + K, from_K, to_K = self.base_field().change_variable_name(names[1]) g = g.map_coefficients(to_K) ret = K.extension(g, names=names[0]) from_ret = ret.hom([self.gen() * d, self.base_field().gen()]) @@ -791,7 +792,7 @@ def free_module(self, base=None, basis=None, map=True): if not map: return V from_V = MapVectorSpaceToFunctionField(V, self) - to_V = MapFunctionFieldToVectorSpace(self, V) + to_V = MapFunctionFieldToVectorSpace(self, V) return (V, from_V, to_V) def maximal_order(self): @@ -982,7 +983,7 @@ def hom(self, im_gens, base_morphism=None): yy |--> y """ - if not isinstance(im_gens, (list,tuple)): + if not isinstance(im_gens, (list, tuple)): im_gens = [im_gens] if len(im_gens) == 0: raise ValueError("no images specified") @@ -1025,11 +1026,11 @@ def genus(self): # making the auxiliary ring which only has polynomials # with integral coefficients. tmpAuxRing = PolynomialRing(self._base_field.constant_field(), - str(self._base_field.gen())+','+str(self._ring.gen())) + str(self._base_field.gen()) + ',' + str(self._ring.gen())) intMinPoly, d = self._make_monic_integral(self._polynomial) curveIdeal = tmpAuxRing.ideal(intMinPoly) - singular.lib('normal.lib') #loading genus method in Singular + singular.lib('normal.lib') # loading genus method in Singular return int(curveIdeal._singular_().genus()) else: @@ -1170,7 +1171,7 @@ def _simple_model(self, name='v'): B = MS(B) M_b = V_to_N(B.solve_left(M_to_V(b))) M_a = V_to_N(B.solve_left(M_to_V(a))) - M_to_N = M.hom([M_a,M_b]) + M_to_N = M.hom([M_a, M_b]) return N, N_to_M, M_to_N @@ -1285,7 +1286,7 @@ def simple_model(self, name=None): if isinstance(self.base_field(), RationalFunctionField): # the extension is simple already if name == self.variable_name(): - id = Hom(self,self).identity() + id = Hom(self, self).identity() return self, id, id else: ret = self.base_field().extension(self.polynomial(), names=(name,)) @@ -1299,8 +1300,8 @@ def simple_model(self, name=None): self_ = base_.extension(self.polynomial().map_coefficients(to_base_), names=(name,)) gens_in_base_ = [to_base_(k.gen()) for k in base._intermediate_fields(base.rational_function_field())] - to_self_ = self.hom([self_.gen()]+gens_in_base_) - from_self_ = self_.hom([self.gen(),from_base_(base_.gen())]) + to_self_ = self.hom([self_.gen()] + gens_in_base_) + from_self_ = self_.hom([self.gen(), from_base_(base_.gen())]) # now collapse self_/base_/K(x) ret, ret_to_self_, self__to_ret = self_._simple_model(name) @@ -1549,8 +1550,8 @@ def separable_model(self, names=None): from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing R = PolynomialRing(self.constant_base_field(), names=names) S = R.remove_var(names[1]) - f = R( L.polynomial().change_variable_name(names[1]).map_coefficients( - lambda c:c.numerator().change_variable_name(names[0]), S)) + f = R(L.polynomial().change_variable_name(names[1]).map_coefficients( + lambda c: c.numerator().change_variable_name(names[0]), S)) f = f.polynomial(R.gen(0)).change_ring(K) f /= f.leading_coefficient() # f must be separable in the other variable (otherwise it would factor) @@ -1558,11 +1559,11 @@ def separable_model(self, names=None): ret = K.extension(f, names=(names[0],)) # isomorphisms between L and ret are given by swapping generators - ret_to_L = ret.hom( [L(L.base_field().gen()), L.gen()] ) - L_to_ret = L.hom( [ret(K.gen()), ret.gen()] ) + ret_to_L = ret.hom([L(L.base_field().gen()), L.gen()]) + L_to_ret = L.hom([ret(K.gen()), ret.gen()]) # compose with from_L and to_L to get the desired isomorphisms between self and ret - f = ret.hom( [from_L(ret_to_L(ret.gen())), from_L(ret_to_L(ret.base_field().gen()))] ) - t = self.hom( [L_to_ret(to_L(self.gen())), L_to_ret(to_L(self.base_field().gen()))] ) + f = ret.hom([from_L(ret_to_L(ret.gen())), from_L(ret_to_L(ret.base_field().gen()))]) + t = self.hom([L_to_ret(to_L(self.gen())), L_to_ret(to_L(self.base_field().gen()))]) return ret, f, t def change_variable_name(self, name): @@ -1637,13 +1638,13 @@ def change_variable_name(self, name): raise ValueError("name must contain at least one string") elif len(name) == 1: base = self.base_field() - from_base = to_base = Hom(base,base).identity() + from_base = to_base = Hom(base, base).identity() else: base, from_base, to_base = self.base_field().change_variable_name(name[1:]) ret = base.extension(self.polynomial().map_coefficients(to_base), names=(name[0],)) - f = ret.hom( [k.gen() for k in self._intermediate_fields(self.rational_function_field())] ) - t = self.hom( [k.gen() for k in ret._intermediate_fields(ret.rational_function_field())] ) + f = ret.hom([k.gen() for k in self._intermediate_fields(self.rational_function_field())]) + t = self.hom([k.gen() for k in ret._intermediate_fields(ret.rational_function_field())]) return ret, f, t @@ -1701,7 +1702,7 @@ def _inversion_isomorphism(self): x |--> x) """ K = self.base_field() - R = PolynomialRing(K,'T') + R = PolynomialRing(K, 'T') x = K.gen() xinv = 1/x @@ -1709,8 +1710,8 @@ def _inversion_isomorphism(self): F_poly = R([h(c) for c in self.polynomial().list()]) F = K.extension(F_poly) - self2F = self.hom([F.gen(),xinv]) - F2self = F.hom([self.gen(),xinv]) + self2F = self.hom([F.gen(), xinv]) + F2self = F.hom([self.gen(), xinv]) M, M2F, F2M = F.monic_integral_model('s') @@ -1844,7 +1845,7 @@ def genus(self): The genus is computed by the Hurwitz genus formula. """ k, _ = self.exact_constant_field() - different_degree = self.different().degree() # must be even + different_degree = self.different().degree() # must be even return Integer(different_degree // 2 - self.degree() / k.degree()) + 1 def residue_field(self, place, name=None): @@ -2123,7 +2124,7 @@ def _places_finite(self, degree): for d in degree.divisors(): for p in K._places_finite(degree=d): - for prime,_,_ in O.decomposition(p.prime_ideal()): + for prime, _, _ in O.decomposition(p.prime_ideal()): place = prime.place() if place.degree() == degree: yield place @@ -2167,7 +2168,7 @@ def _places_infinite(self, degree): """ Oinf = self.maximal_order_infinite() - for prime,_,_ in Oinf.decomposition(): + for prime, _, _ in Oinf.decomposition(): place = prime.place() if place.degree() == degree: yield place @@ -2312,7 +2313,7 @@ def number_of_rational_places(self, r=1): L = self.L_polynomial() Lp = L.derivative() - R = IntegerRing()[[L.parent().gen()]] # power series ring + R = IntegerRing()[[L.parent().gen()]] # power series ring f = R(Lp / L, prec=r) n = f[r-1] + q**r + 1 @@ -2408,13 +2409,13 @@ def _maximal_order_basis(self): from .hermite_form_polynomial import reversed_hermite_form k = self.constant_base_field() - K = self.base_field() # rational function field + K = self.base_field() # rational function field n = self.degree() # Construct the defining polynomial of the function field as a # two-variate polynomial g in the ring k[y,x] where k is the constant # base field. - S,(y,x) = PolynomialRing(k, names='y,x', order='lex').objgens() + S, (y, x) = PolynomialRing(k, names='y,x', order='lex').objgens() v = self.polynomial().list() g = sum([v[i].numerator().subs(x) * y**i for i in range(len(v))]) @@ -2431,7 +2432,7 @@ def _maximal_order_basis(self): gflat = R.zero() for m in g.monomials(): c = g.monomial_coefficient(m).polynomial('zz') - gflat += R(c) * R(m) # R(m) is a monomial in yy and xx + gflat += R(c) * R(m) # R(m) is a monomial in yy and xx k_poly = R(k.polynomial('zz')) @@ -2439,7 +2440,7 @@ def _maximal_order_basis(self): pols_in_R = normalize(R.ideal([k_poly, gflat])) # reconstruct polynomials in S - h = R.hom([y,x,k.gen()],S) + h = R.hom([y, x, k.gen()], S) pols_in_S = [h(f) for f in pols_in_R] else: # Call Singular. Singular's "normal" function returns a basis diff --git a/src/sage/rings/function_field/function_field_rational.py b/src/sage/rings/function_field/function_field_rational.py index 226d87d084c..8a0a6f25764 100644 --- a/src/sage/rings/function_field/function_field_rational.py +++ b/src/sage/rings/function_field/function_field_rational.py @@ -323,7 +323,7 @@ def _to_polynomial(self, f): """ K = f.parent().constant_base_field() if f.denominator() in K: - return f.numerator()/K(f.denominator()) + return f.numerator() / K(f.denominator()) raise ValueError("only polynomials can be converted to the underlying polynomial ring") def _to_bivariate_polynomial(self, f): @@ -350,7 +350,8 @@ 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 @@ -420,12 +421,12 @@ def _factor_univariate_polynomial(self, f, proof=None): x = f.parent().gen() t = f.parent().base_ring().gen() phi = F.parent().hom([x, t]) - v = [(phi(P),e) for P, e in fac] - unit = phi(fac.unit())/d + v = [(phi(P), e) for P, e in fac] + unit = phi(fac.unit()) / d w = [] for a, e in v: c = a.leading_coefficient() - a = a/c + a = a / c # undo any variable substitution that we introduced for the bivariate polynomial if old_variable_name != a.variable_name(): a = a.change_variable_name(old_variable_name) @@ -433,7 +434,7 @@ def _factor_univariate_polynomial(self, f, proof=None): if a.is_unit(): unit *= a**e else: - w.append((a,e)) + w.append((a, e)) from sage.structure.factorization import Factorization return Factorization(w, unit=unit) @@ -553,7 +554,7 @@ def free_module(self, base=None, basis=None, map=True): if not map: return V from_V = MapVectorSpaceToFunctionField(V, self) - to_V = MapFunctionFieldToVectorSpace(self, V) + to_V = MapFunctionFieldToVectorSpace(self, V) return (V, from_V, to_V) def random_element(self, *args, **kwds): @@ -683,7 +684,7 @@ def hom(self, im_gens, base_morphism=None): """ if isinstance(im_gens, CategoryObject): return self.Hom(im_gens).natural_map() - if not isinstance(im_gens, (list,tuple)): + if not isinstance(im_gens, (list, tuple)): im_gens = [im_gens] if len(im_gens) != 1: raise ValueError("there must be exactly one generator") @@ -834,8 +835,8 @@ def change_variable_name(self, name): raise ValueError("names must be a tuple with a single string") name = name[0] if name == self.variable_name(): - id = Hom(self,self).identity() - return self,id,id + id = Hom(self, self).identity() + return self, id, id else: from .constructor import FunctionField ret = FunctionField(self.constant_base_field(), name) diff --git a/src/sage/rings/function_field/ideal_polymod.py b/src/sage/rings/function_field/ideal_polymod.py index 6735dd6a8fa..da45bc508cf 100644 --- a/src/sage/rings/function_field/ideal_polymod.py +++ b/src/sage/rings/function_field/ideal_polymod.py @@ -27,6 +27,7 @@ from .ideal import FunctionFieldIdeal, FunctionFieldIdealInfinite + class FunctionFieldIdeal_polymod(FunctionFieldIdeal): """ Fractional ideals of algebraic function fields @@ -407,7 +408,7 @@ def _mul_(self, other): g1, g2 = other._gens_two_vecs vecs = list(g1 * self._hnf) + [mul(g2, v) for v in self._hnf] else: - vecs = [mul(r1,r2) for r1 in self._hnf for r2 in other._hnf] + vecs = [mul(r1, r2) for r1 in self._hnf for r2 in other._hnf] return O._ideal_from_vectors_and_denominator(vecs, self._denominator * other._denominator) @@ -488,7 +489,7 @@ def intersect(self, other): n = A.ncols() # intersect the row spaces of A and B - M = block_matrix([[I,I],[A,O],[O,B]]) + M = block_matrix([[I, I], [A, O], [O, B]]) # reversed Hermite form U = reversed_hermite_form(M, transformation=True) @@ -601,7 +602,7 @@ def gens_over_base(self): sage: I.gens_over_base() (x^3 + 1, y + x) """ - gens, d = self._gens_over_base + gens, d = self._gens_over_base return tuple([~d * b for b in gens]) @lazy_attribute @@ -620,9 +621,8 @@ def _gens_over_base(self): sage: I._gens_over_base ([x, y], x) """ - gens = [] - for row in self._hnf: - gens.append(sum([c1*c2 for c1,c2 in zip(row, self._ring.basis())])) + gens = [sum([c1 * c2 for c1, c2 in zip(row, self._ring.basis())]) + for row in self._hnf] return gens, self._denominator def gens(self): @@ -864,7 +864,7 @@ def is_prime(self): [True, True] """ factors = self.factor() - if len(factors) == 1 and factors[0][1] == 1: # prime! + if len(factors) == 1 and factors[0][1] == 1: # prime! prime = factors[0][0] assert self == prime self._relative_degree = prime._relative_degree @@ -1013,13 +1013,13 @@ def _factor(self): i = d * self factors = [] - primes = set([o.ideal(p) for p,_ in d.factor()] + [p for p,_ in i.ideal_below().factor()]) + primes = set([o.ideal(p) for p, _ in d.factor()] + [p for p, _ in i.ideal_below().factor()]) for prime in primes: qs = [q[0] for q in O.decomposition(prime)] for q in qs: exp = q.valuation(self) if exp != 0: - factors.append((q,exp)) + factors.append((q, exp)) return factors @@ -1100,10 +1100,10 @@ def __pow__(self, mod): J = [ppow * v for v in I] else: p, q = self._gens_two_vecs - q = sum(e1 * e2 for e1,e2 in zip(O.basis(), q)) + q = sum(e1 * e2 for e1, e2 in zip(O.basis(), q)) ppow = p**mod qpow = O._coordinate_vector(q**mod) - J = [ppow * v for v in I] + [mul(qpow,v) for v in I] + J = [ppow * v for v in I] + [mul(qpow, v) for v in I] return O._ideal_from_vectors_and_denominator(J, self._denominator**mod) @@ -1171,7 +1171,7 @@ def gens_two(self): of Function field in y defined by y^2 + y + (x^2 + 1)/x """ d = self.denominator() - return tuple(e/d for e in self._gens_two()) + return tuple(e / d for e in self._gens_two()) @cached_method def _gens_two(self): @@ -1219,18 +1219,18 @@ def _gens_two(self): O = self.ring() F = O.fraction_field() - if self._kummer_form is not None: # prime ideal + if self._kummer_form is not None: # prime ideal _g1, _g2 = self._kummer_form g1 = F(_g1) - g2 = sum([c1*c2 for c1,c2 in zip(_g2, O.basis())]) + g2 = sum([c1 * c2 for c1, c2 in zip(_g2, O.basis())]) if g2: self._gens_two_vecs = (_g1, _g2) - return (g1,g2) + return (g1, g2) else: self._gens_two_vecs = (_g1,) return (g1,) - ### start to search for two generators + # ---- start to search for two generators hnf = self._hnf @@ -1238,7 +1238,7 @@ def _gens_two(self): for e in hnf.diagonal(): norm *= e - if norm.is_constant(): # unit ideal + if norm.is_constant(): # unit ideal self._gens_two_vecs = (1,) return (F(1),) @@ -1247,7 +1247,7 @@ def _gens_two(self): p = _l.degree() l = F(_l) - if self._hnf == O.ideal(l)._hnf: # principal ideal + if self._hnf == O.ideal(l)._hnf: # principal ideal self._gens_two_vecs = (_l,) return (l,) @@ -1255,13 +1255,13 @@ def _gens_two(self): basis = [] for row in hnf: - basis.append(sum([c1*c2 for c1,c2 in zip(row, O.basis())])) + basis.append(sum([c1 * c2 for c1, c2 in zip(row, O.basis())])) n = len(basis) alpha = None def check(alpha): - alpha_norm = alpha.norm().numerator() # denominator is 1 + alpha_norm = alpha.norm().numerator() # denominator is 1 return norm.gcd(alpha_norm // norm) == 1 # Trial 1: search for alpha among generators @@ -1273,9 +1273,9 @@ def check(alpha): # Trial 2: exhaustive search for alpha using only polynomials # with coefficients 0 or 1 for d in range(p): - G = itertools.product(itertools.product([0,1],repeat=d+1), repeat=n) + G = itertools.product(itertools.product([0, 1], repeat=d + 1), repeat=n) for g in G: - alpha = sum([R(c1)*c2 for c1,c2 in zip(g, basis)]) + alpha = sum([R(c1) * c2 for c1, c2 in zip(g, basis)]) if check(alpha): self._gens_two_vecs = (_l, O._coordinate_vector(alpha)) return (l, alpha) @@ -1293,7 +1293,7 @@ def check(alpha): if g[j].leading_coefficient() != 1: continue - alpha = sum([c1*c2 for c1,c2 in zip(g, basis)]) + alpha = sum([c1 * c2 for c1, c2 in zip(g, basis)]) if check(alpha): self._gens_two_vecs = (_l, O._coordinate_vector(alpha)) return (l, alpha) @@ -1383,7 +1383,7 @@ def __contains__(self, x): True """ F = self.ring().fraction_field() - iF,from_iF,to_iF = F._inversion_isomorphism() + iF, from_iF, to_iF = F._inversion_isomorphism() return to_iF(x) in self._ideal def _add_(self, other): @@ -1580,7 +1580,7 @@ def gens(self): (x, y) """ F = self.ring().fraction_field() - iF,from_iF,to_iF = F._inversion_isomorphism() + iF, from_iF, to_iF = F._inversion_isomorphism() return tuple(from_iF(b) for b in self._ideal.gens()) def gens_two(self): @@ -1606,7 +1606,7 @@ def gens_two(self): (x,) """ F = self.ring().fraction_field() - iF,from_iF,to_iF = F._inversion_isomorphism() + iF, from_iF, to_iF = F._inversion_isomorphism() return tuple(from_iF(b) for b in self._ideal.gens_two()) def gens_over_base(self): @@ -1624,7 +1624,7 @@ def gens_over_base(self): (x, y, 1/x^2*y^2) """ F = self.ring().fraction_field() - iF,from_iF,to_iF = F._inversion_isomorphism() + iF, from_iF, to_iF = F._inversion_isomorphism() return tuple(from_iF(g) for g in self._ideal.gens_over_base()) def ideal_below(self): diff --git a/src/sage/rings/function_field/order_polymod.py b/src/sage/rings/function_field/order_polymod.py index 97f5a625819..067ca2ed090 100644 --- a/src/sage/rings/function_field/order_polymod.py +++ b/src/sage/rings/function_field/order_polymod.py @@ -547,7 +547,7 @@ def codifferent(self): + 6*x/(x^4 + 4*x^3 + 3*x^2 + 6*x + 4)) of Maximal order of Function field in y defined by y^4 + x*y + 4*x + 1 """ - T = self._codifferent_matrix() + T = self._codifferent_matrix() return self._ideal_from_vectors(T.inverse().columns()) @cached_method @@ -686,7 +686,7 @@ def decomposition(self, ideal): 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]] + beta = [c.lift() for c in matrix(m).right_kernel().basis()[0]] r = q index = 1 @@ -1291,7 +1291,7 @@ def decomposition(self, ideal): 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]] + beta = [fr(coeff) for coeff in matrix(m).left_kernel().basis()[0]] prime.is_prime.set_cache(True) prime._prime_below = ideal diff --git a/src/sage/rings/function_field/place_polymod.py b/src/sage/rings/function_field/place_polymod.py index e11a6c86ab7..f345c31129e 100644 --- a/src/sage/rings/function_field/place_polymod.py +++ b/src/sage/rings/function_field/place_polymod.py @@ -463,7 +463,7 @@ def _residue_field(self, name=None): prime = self.prime_ideal() # Let P be this prime ideal if self.is_infinite_place(): - _F, from_F, to_F = F._inversion_isomorphism() + _F, from_F, to_F = F._inversion_isomorphism() _prime = prime._ideal _place = _prime.place() diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py index 8a7f6272da5..b80a4a407ef 100644 --- a/src/sage/rings/number_field/number_field_ideal.py +++ b/src/sage/rings/number_field/number_field_ideal.py @@ -3503,10 +3503,10 @@ def quotient_char_p(I, p): if not I.is_integral(): raise ValueError("I must be an integral ideal.") - K = I.number_field() - OK = K.maximal_order() # will in the long run only really need a p-maximal order. + K = I.number_field() + OK = K.maximal_order() # will in the long run only really need a p-maximal order. M_OK = OK.free_module() - M_I = I.free_module() + M_I = I.free_module() # Now we have to quite explicitly find a way to compute # with OK / I viewed as a quotient of two F_p vector spaces, diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py index 37abe43101e..87221473348 100644 --- a/src/sage/rings/number_field/selmer_group.py +++ b/src/sage/rings/number_field/selmer_group.py @@ -129,7 +129,7 @@ def _coords_in_C_p(I, C, p): """ cyclic_orders = C.gens_orders() non_p_indices = [i for i,n in enumerate(cyclic_orders) if not p.divides(n)] - p_indices = [(i, n // p) for i,n in enumerate(cyclic_orders) if p.divides(n)] + p_indices = [(i, n // p) for i,n in enumerate(cyclic_orders) if p.divides(n)] coords = C(I).exponents() if all(coords[i] == 0 for i in non_p_indices) and all(coords[i] % n == 0 for i, n in p_indices): @@ -227,7 +227,7 @@ def _root_ideal(I, C, p): """ cyclic_orders = C.gens_orders() - cyclic_gens = C.gens_ideals() + cyclic_gens = C.gens_ideals() coords = C(I).exponents() # In the next line, e=(ci/p)%n should satisfy p*e=ci (mod n): we @@ -651,7 +651,7 @@ def to_KSp(a): if debug: assert all(v % p == 0 for v in vals) one = K(1) if K == QQ else K.ideal(1) - aa = a.abs() if K == QQ else K.ideal(a) + aa = a.abs() if K == QQ else K.ideal(a) B = prod((P ** (v // p) for P, v in zip(supp,vals)), one) if debug: assert B ** p == aa diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index fa6655ca516..8f10f30add7 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -405,7 +405,7 @@ def _groebner_basis_magma(self, deg_bound=None, prot=False, magma=magma_default) sage: len(gb) 5 """ - R = self.ring() + R = self.ring() if not deg_bound: mself = magma(self) else: @@ -3615,7 +3615,7 @@ def std(self): ALGORITHM: Uses Singular's ``std`` command """ - if self.side() == 'twosided': + if self.side() == 'twosided': return self.twostd() return self.ring().ideal( self.__call_singular('std'), side=self.side()) # return self.__call_singular('std') diff --git a/src/sage/rings/polynomial/pbori/ll.py b/src/sage/rings/polynomial/pbori/ll.py index a48e7e2a84a..71a01bd3b50 100644 --- a/src/sage/rings/polynomial/pbori/ll.py +++ b/src/sage/rings/polynomial/pbori/ll.py @@ -140,7 +140,7 @@ def eliminate_ll_ranked(ll_system, to_reduce, reduction_function=ll_red_nf_noredsb, reduce_ll_system=False, prot=False): - assert(ll_system) + assert ll_system from_ring = ll_system[0].ring() ll_ranks = rank(ll_system) diff --git a/src/sage/rings/polynomial/term_order.py b/src/sage/rings/polynomial/term_order.py index 687545c0c39..48e49ac89fa 100644 --- a/src/sage/rings/polynomial/term_order.py +++ b/src/sage/rings/polynomial/term_order.py @@ -802,7 +802,7 @@ def __init__(self, name='lex', n=0, force=False): singular_str = [] macaulay2_str = [] - length_pattern = re.compile(r"\(([0-9]+)\)$") # match with parenthesized block length at end + length_pattern = re.compile(r"\(([0-9]+)\)$") # match with parenthesized block length at end for block in block_names: try: block_name, block_length, _ = re.split(length_pattern,block.strip()) @@ -1312,7 +1312,7 @@ def greater_tuple_deglex(self,f,g): """ sf = sum(f.nonzero_values(sort=False)) sg = sum(g.nonzero_values(sort=False)) - return ( sf > sg or ( sf == sg and f > g )) and f or g + return ( sf > sg or ( sf == sg and f > g )) and f or g def greater_tuple_degrevlex(self,f,g): """ @@ -1396,7 +1396,7 @@ def greater_tuple_negdeglex(self,f,g): """ sf = sum(f.nonzero_values(sort=False)) sg = sum(g.nonzero_values(sort=False)) - return ( sf < sg or ( sf == sg and f > g )) and f or g + return ( sf < sg or ( sf == sg and f > g )) and f or g def greater_tuple_degneglex(self,f,g): """ @@ -1474,7 +1474,7 @@ def greater_tuple_wdeglex(self,f,g): """ sf = sum(l*r for (l,r) in zip(f,self._weights)) sg = sum(l*r for (l,r) in zip(g,self._weights)) - return (sf > sg or ( sf == sg and f > g )) and f or g + return (sf > sg or ( sf == sg and f > g )) and f or g def greater_tuple_wdegrevlex(self,f,g): """ @@ -1531,7 +1531,7 @@ def greater_tuple_negwdeglex(self,f,g): """ sf = sum(l*r for (l,r) in zip(f,self._weights)) sg = sum(l*r for (l,r) in zip(g,self._weights)) - return (sf < sg or ( sf == sg and f > g )) and f or g + return (sf < sg or ( sf == sg and f > g )) and f or g def greater_tuple_negwdegrevlex(self,f,g): """ diff --git a/src/sage/rings/quotient_ring_element.py b/src/sage/rings/quotient_ring_element.py index f67c7192f11..56829641624 100644 --- a/src/sage/rings/quotient_ring_element.py +++ b/src/sage/rings/quotient_ring_element.py @@ -422,7 +422,7 @@ def _div_(self, right): # We are computing L/R modulo the ideal. (L, R) = (self.__rep, right.__rep) - P = self.parent() + P = self.parent() I = P.defining_ideal() if not hasattr(I, 'groebner_basis'): diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index 6b84e772dd1..f940adb0755 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -57,7 +57,7 @@ jupyter_execute_default_kernel = 'sagemath' -if os.environ.get('SAGE_LIVE_DOC', 'no') == 'yes': +if os.environ.get('SAGE_LIVE_DOC', 'no') == 'yes': SAGE_JUPYTER_SERVER = os.environ.get('SAGE_JUPYTER_SERVER', 'binder') if SAGE_JUPYTER_SERVER.startswith('binder'): # format: "binder" or @@ -197,7 +197,7 @@ def sphinx_plot(graphics, **kwds): # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # The LaTeX engine to build the docs. # https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-latex_engine @@ -205,9 +205,9 @@ def sphinx_plot(graphics, **kwds): # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of glob-style patterns that should be excluded when looking for # source files. [1] They are matched against the source file names @@ -216,11 +216,11 @@ def sphinx_plot(graphics, **kwds): exclude_patterns = ['.build'] # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. @@ -274,9 +274,9 @@ def set_intersphinx_mappings(app, config): return app.config.intersphinx_mapping = { - 'python': ('https://docs.python.org/', - os.path.join(SAGE_DOC_SRC, "common", - "python{}.inv".format(python_version))), + 'python': ('https://docs.python.org/', + os.path.join(SAGE_DOC_SRC, "common", + "python{}.inv".format(python_version))), } if PPLPY_DOCS and os.path.exists(os.path.join(PPLPY_DOCS, 'objects.inv')): app.config.intersphinx_mapping['pplpy'] = (PPLPY_DOCS, None) @@ -379,18 +379,18 @@ def set_intersphinx_mappings(app, config): html_theme_options = {} # HTML style sheet. This overrides a HTML theme's corresponding setting. -#html_style = 'default.css' +# html_style = 'default.css' # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (within the static path) to place at the top of # the sidebar. -#html_logo = 'sagelogo-word.ico' +# html_logo = 'sagelogo-word.ico' # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 @@ -439,17 +439,17 @@ def set_intersphinx_mappings(app, config): # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_use_modindex = True +# html_use_modindex = True # A list of prefixes that are ignored for sorting the Python module index ( if # this is set to ['foo.'], then foo.bar is shown under B, not F). Works only @@ -852,6 +852,7 @@ def apply(self): node.parent.insert(node.parent.index(node) + 1, cell_node) + # This replaces the setup() in sage.misc.sagedoc_conf def setup(app): app.connect('autodoc-process-docstring', process_docstring_cython) diff --git a/src/tox.ini b/src/tox.ini index f2f1fc158fd..8e562cced8e 100644 --- a/src/tox.ini +++ b/src/tox.ini @@ -162,7 +162,7 @@ description = # W605: invalid escape sequence ‘x’ # See https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes deps = pycodestyle -commands = pycodestyle --select E111,E21,E222,E225,E227,E228,E25,E271,E303,E305,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605 {posargs:{toxinidir}/sage/} +commands = pycodestyle --select E111,E21,E221,E222,E225,E227,E228,E25,E271,E303,E305,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605 {posargs:{toxinidir}/sage/} pycodestyle --select E111,E271,E301,E306,E401,E502,E703,E712,E713,E714,E72,W29,W391,W605, --filename *.pyx {posargs:{toxinidir}/sage/} [pycodestyle]