diff --git a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py index a1fe036917e..8a6002af635 100644 --- a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py +++ b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py @@ -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. @@ -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: diff --git a/src/sage/rings/complex_interval_field.py b/src/sage/rings/complex_interval_field.py index 7cbf5d60929..77364334160 100644 --- a/src/sage/rings/complex_interval_field.py +++ b/src/sage/rings/complex_interval_field.py @@ -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""" diff --git a/src/sage/rings/finite_rings/conway_polynomials.py b/src/sage/rings/finite_rings/conway_polynomials.py index 35604cbcd07..02779f49bca 100644 --- a/src/sage/rings/finite_rings/conway_polynomials.py +++ b/src/sage/rings/finite_rings/conway_polynomials.py @@ -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]: @@ -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] diff --git a/src/sage/rings/finite_rings/finite_field_givaro.py b/src/sage/rings/finite_rings/finite_field_givaro.py index 0a0aa9a8d67..2dd96beeb34 100644 --- a/src/sage/rings/finite_rings/finite_field_givaro.py +++ b/src/sage/rings/finite_rings/finite_field_givaro.py @@ -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): """ diff --git a/src/sage/rings/finite_rings/finite_field_ntl_gf2e.py b/src/sage/rings/finite_rings/finite_field_ntl_gf2e.py index 17161467f12..654f7a2b54b 100644 --- a/src/sage/rings/finite_rings/finite_field_ntl_gf2e.py +++ b/src/sage/rings/finite_rings/finite_field_ntl_gf2e.py @@ -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()) diff --git a/src/sage/rings/finite_rings/homset.py b/src/sage/rings/finite_rings/homset.py index dfce6a12f1a..f9d523199ec 100644 --- a/src/sage/rings/finite_rings/homset.py +++ b/src/sage/rings/finite_rings/homset.py @@ -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): """ diff --git a/src/sage/rings/function_field/constructor.py b/src/sage/rings/function_field/constructor.py index 31156bc9c6f..605e842fa6b 100644 --- a/src/sage/rings/function_field/constructor.py +++ b/src/sage/rings/function_field/constructor.py @@ -86,7 +86,7 @@ def create_key(self, F, names): sage: K. = FunctionField(QQ) # indirect doctest """ if not isinstance(names, tuple): - names=(names,) + names = (names,) return (F, names) def create_object(self, version, key,**extra_args): @@ -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): @@ -170,9 +170,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): diff --git a/src/sage/rings/function_field/divisor.py b/src/sage/rings/function_field/divisor.py index 59f0f7a0cbb..84c837ffb09 100644 --- a/src/sage/rings/function_field/divisor.py +++ b/src/sage/rings/function_field/divisor.py @@ -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): """ diff --git a/src/sage/rings/function_field/function_field_polymod.py b/src/sage/rings/function_field/function_field_polymod.py index cf0dfc439c5..460096c94a1 100644 --- a/src/sage/rings/function_field/function_field_polymod.py +++ b/src/sage/rings/function_field/function_field_polymod.py @@ -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): """ @@ -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): """ diff --git a/src/sage/rings/function_field/function_field_rational.py b/src/sage/rings/function_field/function_field_rational.py index 0332b9ccfed..1b169275da4 100644 --- a/src/sage/rings/function_field/function_field_rational.py +++ b/src/sage/rings/function_field/function_field_rational.py @@ -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): @@ -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): """ @@ -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 diff --git a/src/sage/rings/function_field/order.py b/src/sage/rings/function_field/order.py index 52732cad62a..615cbab3690 100644 --- a/src/sage/rings/function_field/order.py +++ b/src/sage/rings/function_field/order.py @@ -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): @@ -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(),) diff --git a/src/sage/rings/function_field/order_basis.py b/src/sage/rings/function_field/order_basis.py index 3452d961459..eebaeab97d1 100644 --- a/src/sage/rings/function_field/order_basis.py +++ b/src/sage/rings/function_field/order_basis.py @@ -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() diff --git a/src/sage/rings/function_field/order_polymod.py b/src/sage/rings/function_field/order_polymod.py index e4f7d6eece8..97f5a625819 100644 --- a/src/sage/rings/function_field/order_polymod.py +++ b/src/sage/rings/function_field/order_polymod.py @@ -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]] @@ -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 @@ -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]] @@ -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]] @@ -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: diff --git a/src/sage/rings/function_field/order_rational.py b/src/sage/rings/function_field/order_rational.py index ff701315f0f..99da2af1ebd 100644 --- a/src/sage/rings/function_field/order_rational.py +++ b/src/sage/rings/function_field/order_rational.py @@ -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 diff --git a/src/sage/rings/function_field/place_polymod.py b/src/sage/rings/function_field/place_polymod.py index b1d525152f0..e11a6c86ab7 100644 --- a/src/sage/rings/function_field/place_polymod.py +++ b/src/sage/rings/function_field/place_polymod.py @@ -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): diff --git a/src/sage/rings/function_field/place_rational.py b/src/sage/rings/function_field/place_rational.py index b6fd87f4fc2..1930a1d3f66 100644 --- a/src/sage/rings/function_field/place_rational.py +++ b/src/sage/rings/function_field/place_rational.py @@ -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) diff --git a/src/sage/rings/homset.py b/src/sage/rings/homset.py index 6013a6ca28b..876e31bc5aa 100644 --- a/src/sage/rings/homset.py +++ b/src/sage/rings/homset.py @@ -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): """ @@ -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): diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py index 2bb3a47e4d3..53b7140129f 100644 --- a/src/sage/rings/ideal.py +++ b/src/sage/rings/ideal.py @@ -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): """ @@ -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): """ @@ -1276,7 +1276,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""" @@ -1687,7 +1687,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) @@ -1711,7 +1711,7 @@ def __repr__(self): sage: Ideal_fractional(K, [a]) # indirect doctest # optional - 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 diff --git a/src/sage/rings/invariants/invariant_theory.py b/src/sage/rings/invariants/invariant_theory.py index f9b7f6a561b..14d585d8d8b 100644 --- a/src/sage/rings/invariants/invariant_theory.py +++ b/src/sage/rings/invariants/invariant_theory.py @@ -278,7 +278,7 @@ def transvectant(f, g, h=1, scale='default'): elif scale == 'none': scalar = 1 else: - raise ValueError('unknown scale type: %s' %scale) + raise ValueError('unknown scale type: %s' % scale) def diff(j): df = f.form().derivative(x,j).derivative(y,h-j) @@ -533,7 +533,7 @@ def __init__(self, n, d, polynomial, *args, **kwds): elif len(variables) == n-1: variables = variables + (None,) else: - raise ValueError('need '+str(n)+' or '+ + raise ValueError('need '+str(n)+' or ' + str(n-1)+' variables, got '+str(variables)) ring = polynomial.parent() homogeneous = variables[-1] is not None @@ -562,7 +562,7 @@ def _check(self): deg = sum([ e[R.gens().index(x)] for x in self._variables if x is not None ]) degrees.add(deg) - if self._homogeneous and len(degrees)>1: + if self._homogeneous and len(degrees) > 1: raise ValueError('polynomial is not homogeneous') if degrees == set() or \ (self._homogeneous and degrees == set([self._d])) or \ @@ -1492,7 +1492,7 @@ def EisensteinE(self): """ a = self.scaled_coeffs() assert len(a) == 5 - return a[0]*a[3]**2 +a[1]**2*a[4] -a[0]*a[2]*a[4] -2*a[1]*a[2]*a[3] +a[2]**3 + return a[0]*a[3]**2 + a[1]**2*a[4] - a[0]*a[2]*a[4] - 2*a[1]*a[2]*a[3] + a[2]**3 @cached_method def g_covariant(self): @@ -2442,9 +2442,9 @@ def arithmetic_invariants(self): invariants = {} invariants['I4'] = R(2)**-1*5**4*clebsch['A'] invariants['I8'] = 5**5 * (R(2)**-1*47*clebsch['A']**2 - -2**2*clebsch['B']) + - 2**2*clebsch['B']) invariants['I12'] = 5**10 * (R(2)**-1*3*clebsch['A']**3 - -2**5*R(3)**-1*clebsch['C']) + - 2**5*R(3)**-1*clebsch['C']) invariants['I18'] = 2**8*R(3)**-1*5**15 * clebsch['R'] return invariants @@ -2526,9 +2526,9 @@ def _covariant_conic(A_scaled_coeffs, B_scaled_coeffs, monomials): (b0*c1+c0*b1-2*f0*f1) * monomials[0] + (a0*c1+c0*a1-2*g0*g1) * monomials[1] + (a0*b1+b0*a1-2*h0*h1) * monomials[2] + - 2*(f0*g1+g0*f1 -c0*h1-h0*c1) * monomials[3] + - 2*(h0*f1+f0*h1 -b0*g1-g0*b1) * monomials[4] + - 2*(g0*h1+h0*g1 -a0*f1-f0*a1) * monomials[5] ) + 2*(f0*g1+g0*f1 - c0*h1-h0*c1) * monomials[3] + + 2*(h0*f1+f0*h1 - b0*g1-g0*b1) * monomials[4] + + 2*(g0*h1+h0*g1 - a0*f1-f0*a1) * monomials[5] ) ###################################################################### @@ -2856,12 +2856,12 @@ def S_invariant(self): """ a,b,c,a2,a3,b1,b3,c1,c2,m = self.scaled_coeffs() S = ( a*b*c*m-(b*c*a2*a3+c*a*b1*b3+a*b*c1*c2) - -m*(a*b3*c2+b*c1*a3+c*a2*b1) - +(a*b1*c2**2+a*c1*b3**2+b*a2*c1**2+b*c2*a3**2+c*b3*a2**2+c*a3*b1**2) - -m**4+2*m**2*(b1*c1+c2*a2+a3*b3) - -3*m*(a2*b3*c1+a3*b1*c2) - -(b1**2*c1**2+c2**2*a2**2+a3**2*b3**2) - +(c2*a2*a3*b3+a3*b3*b1*c1+b1*c1*c2*a2) ) + - m*(a*b3*c2+b*c1*a3+c*a2*b1) + + (a*b1*c2**2+a*c1*b3**2+b*a2*c1**2+b*c2*a3**2+c*b3*a2**2+c*a3*b1**2) + - m**4+2*m**2*(b1*c1+c2*a2+a3*b3) + - 3*m*(a2*b3*c1+a3*b1*c2) + - (b1**2*c1**2+c2**2*a2**2+a3**2*b3**2) + + (c2*a2*a3*b3+a3*b3*b1*c1+b1*c1*c2*a2) ) return S def T_invariant(self): @@ -2882,35 +2882,35 @@ def T_invariant(self): """ a,b,c,a2,a3,b1,b3,c1,c2,m = self.scaled_coeffs() T = ( a**2*b**2*c**2-6*a*b*c*(a*b3*c2+b*c1*a3+c*a2*b1) - -20*a*b*c*m**3+12*a*b*c*m*(b1*c1+c2*a2+a3*b3) - +6*a*b*c*(a2*b3*c1+a3*b1*c2)+ - 4*(a**2*b*c2**3+a**2*c*b3**3+b**2*c*a3**3+ + - 20*a*b*c*m**3+12*a*b*c*m*(b1*c1+c2*a2+a3*b3) + + 6*a*b*c*(a2*b3*c1+a3*b1*c2) + + 4*(a**2*b*c2**3+a**2*c*b3**3+b**2*c*a3**3 + b**2*a*c1**3+c**2*a*b1**3+c**2*b*a2**3) - +36*m**2*(b*c*a2*a3+c*a*b1*b3+a*b*c1*c2) - -24*m*(b*c*b1*a3**2+b*c*c1*a2**2+c*a*c2*b1**2+c*a*a2*b3**2+a*b*a3*c2**2+ + + 36*m**2*(b*c*a2*a3+c*a*b1*b3+a*b*c1*c2) + - 24*m*(b*c*b1*a3**2+b*c*c1*a2**2+c*a*c2*b1**2+c*a*a2*b3**2+a*b*a3*c2**2 + a*b*b3*c1**2) - -3*(a**2*b3**2*c2**2+b**2*c1**2*a3**2+c**2*a2**2*b1**2)+ + - 3*(a**2*b3**2*c2**2+b**2*c1**2*a3**2+c**2*a2**2*b1**2) + 18*(b*c*b1*c1*a2*a3+c*a*c2*a2*b3*b1+a*b*a3*b3*c1*c2) - -12*(b*c*c2*a3*a2**2+b*c*b3*a2*a3**2+c*a*c1*b3*b1**2+ + - 12*(b*c*c2*a3*a2**2+b*c*b3*a2*a3**2+c*a*c1*b3*b1**2 + c*a*a3*b1*b3**2+a*b*a2*c1*c2**2+a*b*b1*c2*c1**2) - -12*m**3*(a*b3*c2+b*c1*a3+c*a2*b1) - +12*m**2*(a*b1*c2**2+a*c1*b3**2+b*a2*c1**2+ + - 12*m**3*(a*b3*c2+b*c1*a3+c*a2*b1) + + 12*m**2*(a*b1*c2**2+a*c1*b3**2+b*a2*c1**2 + b*c2*a3**2+c*b3*a2**2+c*a3*b1**2) - -60*m*(a*b1*b3*c1*c2+b*c1*c2*a2*a3+c*a2*a3*b1*b3) - +12*m*(a*a2*b3*c2**2+a*a3*c2*b3**2+b*b3*c1*a3**2+ + - 60*m*(a*b1*b3*c1*c2+b*c1*c2*a2*a3+c*a2*a3*b1*b3) + + 12*m*(a*a2*b3*c2**2+a*a3*c2*b3**2+b*b3*c1*a3**2 + b*b1*a3*c1**2+c*c1*a2*b1**2+c*c2*b1*a2**2) - +6*(a*b3*c2+b*c1*a3+c*a2*b1)*(a2*b3*c1+a3*b1*c2) - +24*(a*b1*b3**2*c1**2+a*c1*c2**2*b1**2+b*c2*c1**2*a2**2 - +b*a2*a3**2*c2**2+c*a3*a2**2*b3**2+c*b3*b1**2*a3**2) - -12*(a*a2*b1*c2**3+a*a3*c1*b3**3+b*b3*c2*a3**3+b*b1*a2*c1**3 - +c*c1*a3*b1**3+c*c2*b3*a2**3) - -8*m**6+24*m**4*(b1*c1+c2*a2+a3*b3)-36*m**3*(a2*b3*c1+a3*b1*c2) - -12*m**2*(b1*c1*c2*a2+c2*a2*a3*b3+a3*b3*b1*c1) - -24*m**2*(b1**2*c1**2+c2**2*a2**2+a3**2*b3**2) - +36*m*(a2*b3*c1+a3*b1*c2)*(b1*c1+c2*a2+a3*b3) - +8*(b1**3*c1**3+c2**3*a2**3+a3**3*b3**3) - -27*(a2**2*b3**2*c1**2+a3**2*b1**2*c2**2)-6*b1*c1*c2*a2*a3*b3 - -12*(b1**2*c1**2*c2*a2+b1**2*c1**2*a3*b3+c2**2*a2**2*a3*b3+ + + 6*(a*b3*c2+b*c1*a3+c*a2*b1)*(a2*b3*c1+a3*b1*c2) + + 24*(a*b1*b3**2*c1**2+a*c1*c2**2*b1**2+b*c2*c1**2*a2**2 + + b*a2*a3**2*c2**2+c*a3*a2**2*b3**2+c*b3*b1**2*a3**2) + - 12*(a*a2*b1*c2**3+a*a3*c1*b3**3+b*b3*c2*a3**3+b*b1*a2*c1**3 + + c*c1*a3*b1**3+c*c2*b3*a2**3) + - 8*m**6+24*m**4*(b1*c1+c2*a2+a3*b3)-36*m**3*(a2*b3*c1+a3*b1*c2) + - 12*m**2*(b1*c1*c2*a2+c2*a2*a3*b3+a3*b3*b1*c1) + - 24*m**2*(b1**2*c1**2+c2**2*a2**2+a3**2*b3**2) + + 36*m*(a2*b3*c1+a3*b1*c2)*(b1*c1+c2*a2+a3*b3) + + 8*(b1**3*c1**3+c2**3*a2**3+a3**3*b3**3) + - 27*(a2**2*b3**2*c1**2+a3**2*b1**2*c2**2)-6*b1*c1*c2*a2*a3*b3 + - 12*(b1**2*c1**2*c2*a2+b1**2*c1**2*a3*b3+c2**2*a2**2*a3*b3 + c2**2*a2**2*b1*c1+a3**2*b3**2*b1*c1+a3**2*b3**2*c2*a2) ) return T @@ -3086,8 +3086,8 @@ def syzygy(self, U, S, T, H, Theta, J): return ( -J**2 + 4*Theta**3 + T*U**2*Theta**2 + Theta*(-4*S**3*U**4 + 2*S*T*U**3*H - 72*S**2*U**2*H**2 - 18*T*U*H**3 + 108*S*H**4) - -16*S**4*U**5*H - 11*S**2*T*U**4*H**2 -4*T**2*U**3*H**3 - +54*S*T*U**2*H**4 -432*S**2*U*H**5 -27*T*H**6 ) + - 16*S**4*U**5*H - 11*S**2*T*U**4*H**2 - 4*T**2*U**3*H**3 + + 54*S*T*U**2*H**4 - 432*S**2*U*H**5 - 27*T*H**6 ) ###################################################################### @@ -3967,7 +3967,7 @@ def syzygy(self, Delta, Theta, Phi, Theta_prime, Delta_prime, U, V, T, T_prime, (Theta*Phi - 3*Theta_prime*Delta)*T**2*T_prime + (Theta*Theta_prime - 4*Delta*Delta_prime)*T*T_prime**2 - (Delta_prime*Theta)*T_prime**3 - )* V + \ + ) * V + \ ( (Delta*Phi*Delta_prime) * T**2 + (3*Delta*Theta_prime*Delta_prime - Theta*Phi*Delta_prime) * T*T_prime + (2*Delta*Delta_prime**2 - 2*Theta*Theta_prime*Delta_prime diff --git a/src/sage/rings/lazy_series_ring.py b/src/sage/rings/lazy_series_ring.py index 32545f65574..84ee160e77a 100644 --- a/src/sage/rings/lazy_series_ring.py +++ b/src/sage/rings/lazy_series_ring.py @@ -1019,7 +1019,7 @@ def _test_revert(self, **options): count += 1 e1 = y(x) e2 = x(y) - tester.assertEqual(e1, e2, "y(x) and x(y) differ for x = %s and y = %s" %(x, y)) + tester.assertEqual(e1, e2, "y(x) and x(y) differ for x = %s and y = %s" % (x, y)) # tester.assertEqual(e1, self.gen()) # we want to test at least 2 elements tester.assertGreater(count, 1, msg="only %s elements in %s.some_elements() have a compositional inverse" % (count, self)) diff --git a/src/sage/rings/multi_power_series_ring.py b/src/sage/rings/multi_power_series_ring.py index 410de0bbff0..5670946492a 100644 --- a/src/sage/rings/multi_power_series_ring.py +++ b/src/sage/rings/multi_power_series_ring.py @@ -402,7 +402,7 @@ def _repr_(self): else: generators_rep = ", ".join(self.variable_names()) - s = "Multivariate Power Series Ring in %s over %s"%(generators_rep, self.base_ring()) + s = "Multivariate Power Series Ring in %s over %s" % (generators_rep, self.base_ring()) if self.is_sparse(): s = 'Sparse ' + s return s @@ -419,7 +419,7 @@ def _latex_(self): '\\Bold{Q}[[v_{0}, v_{1}, v_{2}, v_{3}]]' """ generators_latex = ", ".join(self.latex_variable_names()) - return "%s[[%s]]"%(latex.latex(self.base_ring()), generators_latex) + return "%s[[%s]]" % (latex.latex(self.base_ring()), generators_latex) def is_integral_domain(self, proof=False): """ diff --git a/src/sage/rings/multi_power_series_ring_element.py b/src/sage/rings/multi_power_series_ring_element.py index 9aa3f6ea5a4..8a67ca7c551 100644 --- a/src/sage/rings/multi_power_series_ring_element.py +++ b/src/sage/rings/multi_power_series_ring_element.py @@ -593,7 +593,7 @@ def _repr_(self): if self._prec == infinity: return "%s" % self._value() return "%(val)s + O(%(gens)s)^%(prec)s" \ - %{'val':self._value(), + % {'val':self._value(), 'gens':', '.join(str(g) for g in self.parent().gens()), 'prec':self._prec} @@ -628,7 +628,7 @@ def _latex_(self): if self._prec == infinity: return "%s" % self._value()._latex_() return "%(val)s + O(%(gens)s)^{%(prec)s}" \ - %{'val':self._value()._latex_(), + % {'val':self._value()._latex_(), 'gens':', '.join(g._latex_() for g in self.parent().gens()), 'prec':self._prec} @@ -1220,7 +1220,7 @@ def coefficients(self): tmp = {} for j in self._bg_value.coefficients(): for m in j.monomials(): - tmp[self.parent(m)]=j.monomial_coefficient(self.parent()._poly_ring(m)) + tmp[self.parent(m)] = j.monomial_coefficient(self.parent()._poly_ring(m)) return tmp def constant_coefficient(self): diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py index a986e3c513c..92f7af1bf19 100644 --- a/src/sage/rings/number_field/S_unit_solver.py +++ b/src/sage/rings/number_field/S_unit_solver.py @@ -278,7 +278,7 @@ def mus(SUK, v): """ betas = SUK.fundamental_units() beta_and_ns = [[beta,beta.valuation(v)] for beta in betas] - if all(pair[1]==0 for pair in beta_and_ns): + if all(pair[1] == 0 for pair in beta_and_ns): return betas else: good_pair = beta_k(beta_and_ns) @@ -397,7 +397,7 @@ def Yu_a1_kappa1_c1(p, dK, ep): c1 = 1473 else: c1 = 319 - elif p%4 == 1: + elif p % 4 == 1: if ep == 1: c1 = 1473 else: @@ -461,10 +461,10 @@ def Yu_condition_115(K, v): if q == 2: if p**f % 4 == 1: return True - if w%4 == 0: + if w % 4 == 0: return True else: - if w%3 == 0: + if w % 3 == 0: return True return False @@ -1342,7 +1342,7 @@ def log_p_series_part(a, prime, prec): divisor = q.divisors() order = min(d for d in divisor if (a**d - 1).valuation(prime) > 0) - gamma= a**order + gamma = a**order t = 0 while (gamma-1).valuation(prime) <= e: t += 1 @@ -2461,7 +2461,7 @@ def compatible_vectors(a, m0, m1, g): 27 """ # recall that the 0th entry must be an exact match. - ranges = [[a[0]]] + [range(a[i]%g, (a[i]%g) + m1, g) for i in range(1, len(a))] + ranges = [[a[0]]] + [range(a[i] % g, (a[i] % g) + m1, g) for i in range(1, len(a))] return itertools.product(*ranges) diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py index 5be046865f6..2bae4dd2df0 100644 --- a/src/sage/rings/number_field/class_group.py +++ b/src/sage/rings/number_field/class_group.py @@ -102,7 +102,7 @@ def _repr_(self): """ if self.is_principal(): return 'Trivial principal fractional ideal class' - return 'Fractional ideal class %s'%self._value._repr_short() + return 'Fractional ideal class %s' % self._value._repr_short() def _mul_(self, other): r""" @@ -301,7 +301,7 @@ def representative_prime(self, norm_bound=1000): K = Cl.number_field() from sage.rings.real_mpfr import RR for P in K.primes_of_bounded_norm_iter(RR(norm_bound)): - if Cl(P)==c: + if Cl(P) == c: return P raise RuntimeError("No prime of norm less than %s found in class %s" % (norm_bound, c)) @@ -607,10 +607,10 @@ def _repr_(self): sage: C._repr_() 'Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23' """ - s = 'Class group of order %s '%self.order() + s = 'Class group of order %s ' % self.order() if self.order() > 1: - s += 'with structure %s '%self._group_notation(self.gens_orders()) - s += 'of %s'%self.number_field() + s += 'with structure %s ' % self._group_notation(self.gens_orders()) + s += 'of %s' % self.number_field() return s def number_field(self): diff --git a/src/sage/rings/number_field/homset.py b/src/sage/rings/number_field/homset.py index a28660ca5d0..cb61df73344 100644 --- a/src/sage/rings/number_field/homset.py +++ b/src/sage/rings/number_field/homset.py @@ -143,7 +143,7 @@ def _an_element_(self): else: from sage.categories.sets_cat import EmptySetError raise EmptySetError("There is no morphism from {} to {}".format( - self.domain(), self.codomain())) + self.domain(), self.codomain())) def _repr_(self): r""" @@ -238,7 +238,7 @@ def list(self): v = [D.hom([r], codomain=C, check=False) for r in roots] else: v = [] - return Sequence(v, universe=self, check=False, immutable=True, cr=v!=[]) + return Sequence(v, universe=self, check=False, immutable=True, cr=bool(v)) def __getitem__(self, n): r""" @@ -389,7 +389,7 @@ def _element_constructor_(self, x, base_map=None, base_hom=None, check=True): raise ValueError("codomain of absolute homomorphism must be codomain of this homset.") return self.element_class(self, x) if (isinstance(x, RelativeNumberFieldHomomorphism_from_abs) - and x.parent() == self): + and x.parent() == self): return self.element_class(self, x.abs_hom()) if base_map is None: base_map = self.default_base_hom() @@ -519,7 +519,7 @@ def list(self): C = self.codomain() D_abs = D.absolute_field('a') v = [self(f, check=False) for f in D_abs.Hom(C).list()] - return Sequence(v, universe=self, check=False, immutable=True, cr=v!=[]) + return Sequence(v, universe=self, check=False, immutable=True, cr=bool(v)) class CyclotomicFieldHomset(NumberFieldHomset): @@ -579,7 +579,7 @@ def _element_constructor_(self, x, check=True): x^2 + b """ if (isinstance(x, CyclotomicFieldHomomorphism_im_gens) - and x.parent() == self): + and x.parent() == self): return self.element_class(self, x.im_gens()) return self.element_class(self, x, check=check) @@ -615,11 +615,11 @@ def list(self): z = D.gen() n = z.multiplicative_order() if not n.divides(C.zeta_order()): - v =[] + v = [] else: if D == C: w = z else: w = C.zeta(n) v = [self([w**k], check=False) for k in Zmod(n) if k.is_unit()] - return Sequence(v, universe=self, check=False, immutable=True, cr=v!=[]) + return Sequence(v, universe=self, check=False, immutable=True, cr=bool(v)) diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py index b5e724a0ab4..924eaa2177f 100644 --- a/src/sage/rings/number_field/number_field_ideal.py +++ b/src/sage/rings/number_field/number_field_ideal.py @@ -133,7 +133,7 @@ def __init__(self, field, gens, coerce=True): else: # Assume one element of the field gens = [field(gens, check=False)] - if len(gens)==0: + if len(gens) == 0: raise ValueError("gens must have length at least 1 (zero ideal is not a fractional ideal)") Ideal_generic.__init__(self, field, gens, coerce) if field.absolute_degree() == 2: @@ -288,8 +288,8 @@ def _mul_(self, other): if self.ngens() == 1 and other.ngens() == 1: return self.ring().ideal(self.gen(0) * other.gen(0)) - K=self.ring() - K_pari=K.pari_nf() + K = self.ring() + K_pari = K.pari_nf() return K.ideal(K_pari.idealmul(self, other)) def coordinates(self, x): @@ -2472,7 +2472,7 @@ def is_coprime(self, other): N1 = self.numerator() D2 = other.denominator() N2 = other.numerator() - return N1+N2==one and N1+D2==one and D1+N2==one and D1+D2==one + return N1+N2 == one and N1+D2 == one and D1+N2 == one and D1+D2 == one def idealcoprime(self, J): """ @@ -2651,7 +2651,7 @@ def idealstar(self, flag=1): ALGORITHM: Uses Pari function :pari:`idealstar` """ k = self.number_field() - if flag==0 and not hasattr(self, '_bid'): + if flag == 0 and not hasattr(self, '_bid'): G = k.pari_nf().idealstar(self.pari_hnf(), 0) else: G = self._pari_bid_(flag) diff --git a/src/sage/rings/number_field/number_field_ideal_rel.py b/src/sage/rings/number_field/number_field_ideal_rel.py index e19d0df9c1c..5ef403e7e23 100644 --- a/src/sage/rings/number_field/number_field_ideal_rel.py +++ b/src/sage/rings/number_field/number_field_ideal_rel.py @@ -687,7 +687,7 @@ def absolute_ramification_index(self): """ if self.is_prime(): return self.absolute_ideal().ramification_index() - raise ValueError("the fractional ideal (= %s) is not prime"%self) + raise ValueError("the fractional ideal (= %s) is not prime" % self) def relative_ramification_index(self): """ @@ -722,7 +722,7 @@ def relative_ramification_index(self): abs_index = self.absolute_ramification_index() base_ideal = self.ideal_below() return ZZ(abs_index/base_ideal.absolute_ramification_index()) - raise ValueError("the fractional ideal (= %s) is not prime"%self) + raise ValueError("the fractional ideal (= %s) is not prime" % self) def ramification_index(self): r""" @@ -758,7 +758,7 @@ def residue_class_degree(self): """ if self.is_prime(): return self.absolute_ideal().residue_class_degree() - raise ValueError("the ideal (= %s) is not prime"%self) + raise ValueError("the ideal (= %s) is not prime" % self) def residues(self): """ @@ -815,14 +815,14 @@ def element_1_mod(self, other): # Catch invalid inputs by making sure that we can make an ideal out of other. K = self.number_field() if not self.is_integral(): - raise TypeError("%s is not an integral ideal"%self) + raise TypeError("%s is not an integral ideal" % self) other = K.ideal(other) if not other.is_integral(): - raise TypeError("%s is not an integral ideal"%other) + raise TypeError("%s is not an integral ideal" % other) if not self.is_coprime(other): - raise TypeError("%s and %s are not coprime ideals"%(self, other)) + raise TypeError("%s and %s are not coprime ideals" % (self, other)) to_K = K.absolute_field('a').structure()[0] return to_K(self.absolute_ideal().element_1_mod(other.absolute_ideal())) @@ -874,13 +874,13 @@ def valuation(self, p): ValueError: p (= Fractional ideal (5)) must be a prime """ if p == 0: - raise ValueError("p (= %s) must be nonzero"%p) + raise ValueError("p (= %s) must be nonzero" % p) if not isinstance(p, NumberFieldFractionalIdeal): p = self.number_field().ideal(p) if not p.is_prime(): - raise ValueError("p (= %s) must be a prime"%p) + raise ValueError("p (= %s) must be a prime" % p) if p.ring() != self.number_field(): - raise ValueError("p (= %s) must be an ideal in %s"%self.number_field()) + raise ValueError("p (= %s) must be an ideal in %s" % self.number_field()) return self.absolute_ideal().valuation(p.absolute_ideal()) def is_NumberFieldFractionalIdeal_rel(x): diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py index 2e2989d413f..1e8a6a17fe1 100644 --- a/src/sage/rings/number_field/number_field_rel.py +++ b/src/sage/rings/number_field/number_field_rel.py @@ -281,7 +281,7 @@ def __init__(self, base, polynomial, name, if names is not None: name = names if not isinstance(base, NumberField_base): - raise TypeError("base (=%s) must be a number field"%base) + raise TypeError("base (=%s) must be a number field" % base) if not isinstance(polynomial, polynomial_element.Polynomial): try: polynomial = polynomial.polynomial(base) @@ -313,7 +313,7 @@ def __init__(self, base, polynomial, name, self._element_class = number_field_element.NumberFieldElement_relative if check and not self.pari_relative_polynomial().polisirreducible(): - raise ValueError("defining polynomial (%s) must be irreducible"%polynomial) + raise ValueError("defining polynomial (%s) must be irreducible" % polynomial) names = (name,) + base.variable_names() self._assign_names(tuple(names), normalize=False) @@ -463,7 +463,7 @@ def subfields(self, degree=0, name=None): if to_K is not None: to_K = RelativeNumberFieldHomomorphism_from_abs(self.Hom(K), to_K*to_abs) ans.append((K, from_K, to_K)) - ans = Sequence(ans, immutable=True, cr=ans!=[]) + ans = Sequence(ans, immutable=True, cr=bool(ans)) return ans def is_absolute(self): @@ -753,7 +753,7 @@ def _repr_(self): Number Field in b with defining polynomial x^7 + 3 """ - return "Number Field in %s with defining polynomial %s over its base field"%(self.variable_name(), self.relative_polynomial()) + return "Number Field in %s with defining polynomial %s over its base field" % (self.variable_name(), self.relative_polynomial()) def _Hom_(self, codomain, category=None): """ @@ -798,7 +798,7 @@ def _latex_(self): '( \\Bold{Q}[a]/(a^{3} - 2) )[b]/(b^{2} + b + a)' """ latex_name = self.latex_variable_names()[0] - return "( %s )[%s]/(%s)"%(latex(self.base_field()), latex_name, + return "( %s )[%s]/(%s)" % (latex(self.base_field()), latex_name, self.relative_polynomial()._latex_(latex_name)) def _coerce_from_other_number_field(self, x): @@ -2077,7 +2077,7 @@ def embeddings(self, K): # then it is most natural, so we put it first. put_natural_embedding_first(v) - self.__embeddings[K] = Sequence(v, cr=v!=[], immutable=True, check=False, universe=self.Hom(K)) + self.__embeddings[K] = Sequence(v, cr=bool(v), immutable=True, check=False, universe=self.Hom(K)) return self.__embeddings[K] def automorphisms(self): @@ -2152,13 +2152,14 @@ def automorphisms(self): L = self.absolute_field('a') L_into_self, self_into_L = L.structure() - aas = L.automorphisms() # absolute automorphisms + aas = L.automorphisms() # absolute automorphisms a = self_into_L(self.gen()) abs_base_gens = [self_into_L(_) for _ in self.base_field().gens()] - v = sorted([ self.hom([ L_into_self(aa(a)) ]) for aa in aas if all(aa(g) == g for g in abs_base_gens) ]) + v = sorted([self.hom([L_into_self(aa(a))]) for aa in aas + if all(aa(g) == g for g in abs_base_gens)]) put_natural_embedding_first(v) - self.__automorphisms = Sequence(v, cr=(v != []), immutable=True, + self.__automorphisms = Sequence(v, cr=bool(v), immutable=True, check=False, universe=self.Hom(self)) return self.__automorphisms @@ -2576,7 +2577,7 @@ def lift_to_base(self, element): # Now we should have a polynomial in the variable y. # Otherwise we're not in the base field. if r.type() != "t_POL" or str(r.variable()) != 'y': - raise ValueError("The element %s is not in the base field"%element) + raise ValueError("The element %s is not in the base field" % element) return self.base_field()(r, check=False) def relativize(self, alpha, names): @@ -2711,7 +2712,7 @@ def uniformizer(self, P, others="positive"): if not is_NumberFieldIdeal(P): P = self.ideal(P) if not P.is_maximal(): - raise ValueError("P (=%s) must be a nonzero prime."%P) + raise ValueError("P (=%s) must be a nonzero prime." % P) abs = self.absolute_field('a') from_abs = abs.structure()[0] return from_abs(abs.uniformizer(P.absolute_ideal(), others=others)) diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py index 77e1f4a84d8..37abe43101e 100644 --- a/src/sage/rings/number_field/selmer_group.py +++ b/src/sage/rings/number_field/selmer_group.py @@ -286,7 +286,7 @@ def coords_in_U_mod_p(u, U, p): """ coords = U.log(u) start = 1 - int(p.divides(U.zeta_order())) # 0 or 1 - return [c%p for c in coords[start:]] + return [c % p for c in coords[start:]] def basis_for_p_cokernel(S, C, p): r""" @@ -548,7 +548,7 @@ def pSelmerGroup(K, S, p, proof=None, debug=False): hK = 1 if K == QQ else K.class_number(proof=proof) C = K.class_group() if K == QQ else K.class_group(proof=proof) - hKp = (hK%p == 0) # flag whether the class number is divisible by p + hKp = (hK % p == 0) # flag whether the class number is divisible by p if K == QQ: if p == 2: @@ -684,7 +684,7 @@ def to_KSp(a): if debug: print("B={}".format(B)) - a3 = B if K==QQ else _ideal_generator(B) + a3 = B if K == QQ else _ideal_generator(B) if debug: print("a3={}".format(a3)) a /= a3 ** p @@ -699,7 +699,7 @@ def to_KSp(a): if debug: if K == QQ: - assert a.abs()==1 + assert a.abs() == 1 else: assert K.ideal(a).is_one() diff --git a/src/sage/rings/number_field/splitting_field.py b/src/sage/rings/number_field/splitting_field.py index 448adc6b529..927ecb3b5fb 100644 --- a/src/sage/rings/number_field/splitting_field.py +++ b/src/sage/rings/number_field/splitting_field.py @@ -109,7 +109,7 @@ def __repr__(self): sage: print(SplittingData(pari("polcyclo(24)"), 2)) SplittingData(x^8 - x^4 + 1, 2) """ - return "SplittingData(%s, %s)"%(self.pol, self.dm) + return "SplittingData(%s, %s)" % (self.pol, self.dm) def _repr_tuple(self): """ @@ -391,7 +391,7 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No # (only needed if map=True) if map: Fgen = F.gen().__pari__() - verbose("Starting field: %s"%Kpol) + verbose("Starting field: %s" % Kpol) # L and Lred are lists of SplittingData. # L contains polynomials which are irreducible over K, @@ -415,7 +415,7 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No raise SplittingFieldAbort(absolute_degree * rel_degree_divisor, degree_multiple) # First, factor polynomials in Lred and store the result in L - verbose("SplittingData to factor: %s"%[s._repr_tuple() for s in Lred]) + verbose("SplittingData to factor: %s" % [s._repr_tuple() for s in Lred]) t = cputime() for splitting in Lred: m = splitting.dm.gcd(degree_multiple).gcd(factorial(splitting.poldegree())) @@ -455,7 +455,7 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No # Compute cubic resolvent a0, a1, a2, a3, a4 = (q/q.pollead()).Vecrev() assert a4 == 1 - cubicpol = pari([4*a0*a2 - a1*a1 -a0*a3*a3, a1*a3 - 4*a0, -a2, 1]).Polrev() + cubicpol = pari([4*a0*a2 - a1*a1 - a0*a3*a3, a1*a3 - 4*a0, -a2, 1]).Polrev() cubicfactors = Kpol.nffactor(cubicpol)[0] if len(cubicfactors) == 1: # A4 or S4 # After adding a root of the cubic resolvent, @@ -505,8 +505,8 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No # Sort according to degree to handle low degrees first L.sort(key=lambda x: x.key()) - verbose("SplittingData to handle: %s"%[s._repr_tuple() for s in L]) - verbose("Bounds for absolute degree: [%s, %s]"%(degree_divisor,degree_multiple)) + verbose("SplittingData to handle: %s" % [s._repr_tuple() for s in L]) + verbose("Bounds for absolute degree: [%s, %s]" % (degree_divisor,degree_multiple)) # Check consistency if degree_multiple % degree_divisor != 0: @@ -525,7 +525,7 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No # Add a root of f = L[0] to construct the field N = K[x]/f(x) splitting = L[0] f = splitting.pol - verbose("Handling polynomial %s"%(f.lift()), level=2) + verbose("Handling polynomial %s" % (f.lift()), level=2) t = cputime() Npol, KtoN, k = Kpol.rnfequation(f, flag=1) @@ -547,7 +547,7 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No if simplify_all or (simplify and not finished): # Find a simpler defining polynomial Lpol for Mpol - verbose("New field before simplifying: %s"%Mpol, t) + verbose("New field before simplifying: %s" % Mpol, t) t = cputime() M = Mpol.polred(flag=3) n = len(M[0])-1 @@ -562,7 +562,7 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No NtoL = MtoL/Mdiv KtoL = KtoN.lift().subst("x", NtoL).Mod(Lpol) Kpol = Lpol # New Kpol (for next iteration) - verbose("New field: %s"%Kpol, t) + verbose("New field: %s" % Kpol, t) if map: t = cputime() Fgen = Fgen.lift().subst("y", KtoL) diff --git a/src/sage/rings/number_field/totallyreal_phc.py b/src/sage/rings/number_field/totallyreal_phc.py index 890a0a2f469..4143feb67b3 100644 --- a/src/sage/rings/number_field/totallyreal_phc.py +++ b/src/sage/rings/number_field/totallyreal_phc.py @@ -126,12 +126,12 @@ def __lagrange_bounds_phc(n, m, a, tmpfile=None): for P in sage.combinat.partition.Partitions(n-1,length=m-1): f = open(tmpfile, 'w') # First line: number of variables/equations - f.write('%d'%m + '\n') + f.write('%d' % m + '\n') # In the next m-1 lines, write the equation S_j(x) = S[j] for j in range(1,m+1): for i in range(m-1): - f.write('%d'%P[i] + '*x%d'%i + '**%d'%j + ' + ') - f.write('xn**%d'%j + ' - (%d'%S[j] + ');\n') + f.write('%d' % P[i] + '*x%d' % i + '**%d' % j + ' + ') + f.write('xn**%d' % j + ' - (%d' % S[j] + ');\n') f.close() os.remove(tmpfile + '.phc') diff --git a/src/sage/rings/number_field/totallyreal_rel.py b/src/sage/rings/number_field/totallyreal_rel.py index 65026b38885..d7039c26c86 100644 --- a/src/sage/rings/number_field/totallyreal_rel.py +++ b/src/sage/rings/number_field/totallyreal_rel.py @@ -300,7 +300,7 @@ def __init__(self, F, m, B, a=None): import numpy for i in range(len(anm1s)): Q = [[v(m*x) for v in self.Foo] + [0] for x in Z_Fbasis] + [[v(anm1s[i]) for v in self.Foo] + [10**6]] - pari_string = '['+';'.join([','.join(["%s"%ii for ii in row]) for row in zip(*Q)])+']' + pari_string = '['+';'.join([','.join(["%s" % ii for ii in row]) for row in zip(*Q)])+']' adj = pari(pari_string).qflll()[self.d] anm1s[i] += sum([m*Z_Fbasis[ii]*int(adj[ii])//int(adj[self.d]) for ii in range(self.d)]) @@ -322,7 +322,7 @@ def __init__(self, F, m, B, a=None): # currently unknown; e.g., if k == -1, then we can iterate # over polynomials, and if k == n-1, then we have finished iterating. if a[len(a)-1] != 1: - raise ValueError("a[len(a)-1](=%s) must be 1 so polynomial is monic"%a[len(a)-1]) + raise ValueError("a[len(a)-1](=%s) must be 1 so polynomial is monic" % a[len(a)-1]) raise NotImplementedError("These have not been checked.") diff --git a/src/sage/rings/number_field/unit_group.py b/src/sage/rings/number_field/unit_group.py index 42c3933219b..5f9d5c0654c 100644 --- a/src/sage/rings/number_field/unit_group.py +++ b/src/sage/rings/number_field/unit_group.py @@ -321,12 +321,12 @@ def __init__(self, number_field, proof=True, S=None): try: S = tuple(K.ideal(S).prime_factors()) except (NameError, TypeError, ValueError): - raise ValueError("Cannot make a set of primes from %s"%(S,)) + raise ValueError("Cannot make a set of primes from %s" % (S,)) else: try: S = tuple(K.ideal(P) for P in S) except (NameError, TypeError, ValueError): - raise ValueError("Cannot make a set of primes from %s"%(S,)) + raise ValueError("Cannot make a set of primes from %s" % (S,)) if not all(P.is_prime() for P in S): raise ValueError("Not all elements of %s are prime ideals" % (S,)) self.__S = S @@ -398,14 +398,14 @@ def _element_constructor_(self, u): try: u = K(u) except TypeError: - raise ValueError("%s is not an element of %s"%(u,K)) + raise ValueError("%s is not an element of %s" % (u,K)) if self.__S: m = pK.bnfisunit(pari(u), self.__S_unit_data).mattranspose() if m.ncols() == 0: - raise ValueError("%s is not an S-unit"%u) + raise ValueError("%s is not an S-unit" % u) else: if not u.is_integral() or u.norm().abs() != 1: - raise ValueError("%s is not a unit"%u) + raise ValueError("%s is not a unit" % u) m = pK.bnfisunit(pari(u)).mattranspose() # convert column matrix to a list: @@ -448,11 +448,11 @@ def _repr_(self): with S = (Fractional ideal (a),) """ if self.__S: - return 'S-unit group with structure %s of %s with S = %s'%( + return 'S-unit group with structure %s of %s with S = %s' % ( self._group_notation(self.gens_orders()), self.number_field(), self.primes()) - return 'Unit group with structure %s of %s'%( + return 'Unit group with structure %s of %s' % ( self._group_notation(self.gens_orders()), self.number_field()) @@ -561,7 +561,7 @@ def zeta(self, n=2, all=False): K = self.number_field() n = ZZ(n) if n <= 0: - raise ValueError("n (=%s) must be positive"%n) + raise ValueError("n (=%s) must be positive" % n) if n == 1: if all: return [K(1)] @@ -582,7 +582,7 @@ def zeta(self, n=2, all=False): if all: return [] else: - raise ValueError("n (=%s) does not divide order of generator"%n) + raise ValueError("n (=%s) does not divide order of generator" % n) def number_field(self): """ diff --git a/src/sage/rings/padics/factory.py b/src/sage/rings/padics/factory.py index e001b9e5086..d8d7c7e3c3b 100644 --- a/src/sage/rings/padics/factory.py +++ b/src/sage/rings/padics/factory.py @@ -301,7 +301,7 @@ def get_key_base(p, prec, type, print_mode, names, ram_name, print_pos, print_se if not isinstance(print_ram_name, str): print_ram_name = str(print_ram_name) if names != print_ram_name: - raise ValueError("If both names (%s) and print_ram_name (%s) are specified, they must agree"%(names, print_ram_name)) + raise ValueError("If both names (%s) and print_ram_name (%s) are specified, they must agree" % (names, print_ram_name)) name = names else: if names is None: @@ -311,7 +311,7 @@ def get_key_base(p, prec, type, print_mode, names, ram_name, print_pos, print_se else: name = str(names) if type not in valid_types: - raise ValueError("type must be %s"%(", ".join(valid_types))) + raise ValueError("type must be %s" % (", ".join(valid_types))) show_prec = _canonicalize_show_prec(type, print_mode, show_prec) key = (p, prec, type, print_mode, name, print_pos, print_sep, tuple(print_alphabet), print_max_terms, show_prec, label) return key @@ -1343,7 +1343,7 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, k = Integer(k) if check: - if not p.is_prime() or k <=0: + if not p.is_prime() or k <= 0: raise ValueError("q must be a prime power") if prec is not None and not isinstance(prec, Integer): diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py index c3d9dce2ded..0832f317b4d 100644 --- a/src/sage/rings/padics/generic_nodes.py +++ b/src/sage/rings/padics/generic_nodes.py @@ -1471,7 +1471,7 @@ def random_element(self, algorithm='default'): else: return self(ZZ.random_element(self.prime_pow.pow_Integer_Integer(self.precision_cap()))) else: - raise NotImplementedError("Don't know %s algorithm"%algorithm) + raise NotImplementedError("Don't know %s algorithm" % algorithm) #def unit_group(self): # raise NotImplementedError diff --git a/src/sage/rings/padics/lattice_precision.py b/src/sage/rings/padics/lattice_precision.py index d2ad57b869d..9c76ff88362 100644 --- a/src/sage/rings/padics/lattice_precision.py +++ b/src/sage/rings/padics/lattice_precision.py @@ -676,9 +676,9 @@ def _repr_(self): sage: R.precision() Precision lattice on 0 objects (label: mylabel) """ - label = "" if self._label is None else " (label: %s)"%(self._label,) - count = "1 object" if len(self._elements) == 1 else "%s objects"%len(self._elements) - return "%s on %s%s"%(self._repr_type, count, label) + label = "" if self._label is None else " (label: %s)" % (self._label,) + count = "1 object" if len(self._elements) == 1 else "%s objects" % len(self._elements) + return "%s on %s%s" % (self._repr_type, count, label) def threshold_deletion(self, threshold=None): r""" @@ -2786,7 +2786,7 @@ def __init__(self, element, callback=None): """ if not hasattr(element, '_proxy_id'): element._proxy_id = pAdicLatticeElementWeakProxy._next_id - pAdicLatticeElementWeakProxy._next_id +=1 + pAdicLatticeElementWeakProxy._next_id += 1 self._id = element._proxy_id from weakref import ref proxy_callback = callback @@ -2856,7 +2856,7 @@ def __repr__(self): [WeakProxy#...] """ - return "WeakProxy#%s"%(self._id,) + return "WeakProxy#%s" % (self._id,) def list_of_padics(elements): r""" diff --git a/src/sage/rings/padics/local_generic.py b/src/sage/rings/padics/local_generic.py index 6dbebfb5347..5726055d2be 100644 --- a/src/sage/rings/padics/local_generic.py +++ b/src/sage/rings/padics/local_generic.py @@ -452,7 +452,7 @@ def get_unramified_modulus(q, res_name): functor.extras = copy(functor.extras) functor.extras['print_mode'] = copy(functor.extras['print_mode']) if 'type' in kwds and kwds['type'] not in functor._dvr_types: - raise ValueError("completion type must be one of %s"%(", ".join(functor._dvr_types[1:]))) + raise ValueError("completion type must be one of %s" % (", ".join(functor._dvr_types[1:]))) if 'field' in kwds: field = kwds.pop('field') if field: @@ -493,7 +493,7 @@ def get_unramified_modulus(q, res_name): if atr in kwds: functor.extras['print_mode'][atr] = kwds.pop(atr) if kwds: - raise ValueError("Extra arguments received: %s"%(", ".join(kwds.keys()))) + raise ValueError("Extra arguments received: %s" % (", ".join(kwds.keys()))) if q is not None: # Create an unramified extension base = functor(ring) diff --git a/src/sage/rings/padics/misc.py b/src/sage/rings/padics/misc.py index 46b261c95dc..b535dbb07c5 100644 --- a/src/sage/rings/padics/misc.py +++ b/src/sage/rings/padics/misc.py @@ -201,10 +201,10 @@ def precprint(prec_type, prec_cap, p): sage: precprint('fixed-mod', 1, 17) 'of fixed modulus 17^1' """ - precD = {'capped-rel':'with capped relative precision %s'%prec_cap, - 'capped-abs':'with capped absolute precision %s'%prec_cap, - 'floating-point':'with floating precision %s'%prec_cap, - 'fixed-mod':'of fixed modulus %s^%s'%(p, prec_cap), + precD = {'capped-rel':'with capped relative precision %s' % prec_cap, + 'capped-abs':'with capped absolute precision %s' % prec_cap, + 'floating-point':'with floating precision %s' % prec_cap, + 'fixed-mod':'of fixed modulus %s^%s' % (p, prec_cap), 'lattice-cap':'with lattice-cap precision', 'lattice-float':'with lattice-float precision', 'relaxed':'handled with relaxed arithmetics'} diff --git a/src/sage/rings/padics/padic_base_generic.py b/src/sage/rings/padics/padic_base_generic.py index 56f241fd777..6fb5f464a7f 100644 --- a/src/sage/rings/padics/padic_base_generic.py +++ b/src/sage/rings/padics/padic_base_generic.py @@ -133,12 +133,12 @@ def _repr_(self, do_latex=False): else: s = r"\Bold{Z}_{%s}" % self.prime() if hasattr(self, '_label') and self._label: - s = r"\verb'%s' (\simeq %s)"%(self._label, s) + s = r"\verb'%s' (\simeq %s)" % (self._label, s) else: s = "Field " if self.is_field() else "Ring " - s = "%s-adic "%self.prime() + s + precprint(self._prec_type(), self.precision_cap(), self.prime()) + s = "%s-adic " % self.prime() + s + precprint(self._prec_type(), self.precision_cap(), self.prime()) if hasattr(self, '_label') and self._label: - s+= " (label: %s)"%self._label + s += " (label: %s)" % self._label return s def exact_field(self): @@ -387,7 +387,7 @@ def zeta(self, n=None): if n == 1: return self(1) else: - raise ValueError("No, %sth root of unity in self"%n) + raise ValueError("No, %sth root of unity in self" % n) else: from sage.rings.finite_rings.finite_field_constructor import GF return self.teichmuller(GF(self.prime()).zeta(n).lift()) diff --git a/src/sage/rings/padics/padic_base_leaves.py b/src/sage/rings/padics/padic_base_leaves.py index 8c4636e2904..1c47b0083c2 100644 --- a/src/sage/rings/padics/padic_base_leaves.py +++ b/src/sage/rings/padics/padic_base_leaves.py @@ -731,7 +731,7 @@ def random_element(self, algorithm='default'): a = ZZ.random_element(self.prime()**self.precision_cap()) return self(self.prime()**k * a, absprec=k + self.precision_cap()) else: - raise NotImplementedError("Don't know %s algorithm"%algorithm) + raise NotImplementedError("Don't know %s algorithm" % algorithm) class pAdicFieldFloatingPoint(pAdicFieldBaseGeneric, pAdicFloatingPointFieldGeneric): r""" diff --git a/src/sage/rings/padics/padic_generic.py b/src/sage/rings/padics/padic_generic.py index 769b8500c7d..a929ee60a75 100644 --- a/src/sage/rings/padics/padic_generic.py +++ b/src/sage/rings/padics/padic_generic.py @@ -1045,7 +1045,7 @@ def _test_teichmuller(self, **options): try: y = self.teichmuller(x) except ValueError: - tester.assertTrue(x.valuation() < 0 or x.precision_absolute()==0) + tester.assertTrue(x.valuation() < 0 or x.precision_absolute() == 0) else: try: tester.assertEqual(x.residue(), y.residue()) diff --git a/src/sage/rings/padics/padic_valuation.py b/src/sage/rings/padics/padic_valuation.py index dbd8830a4d4..b6ea2ea75ee 100644 --- a/src/sage/rings/padics/padic_valuation.py +++ b/src/sage/rings/padics/padic_valuation.py @@ -136,7 +136,7 @@ def create_key_and_extra_args(self, R, prime=None, approximants=None): elif isinstance(R.fraction_field(), NumberField) or is_PolynomialQuotientRing(R): return self.create_key_and_extra_args_for_number_field(R, prime, approximants=approximants) else: - raise NotImplementedError("p-adic valuations not implemented for %r"%(R,)) + raise NotImplementedError("p-adic valuations not implemented for %r" % (R,)) def create_key_for_integers(self, R, prime): r""" @@ -156,7 +156,7 @@ def create_key_for_integers(self, R, prime): if isinstance(prime, DiscretePseudoValuation): prime = prime.uniformizer() if prime not in ZZ or not ZZ(prime).is_prime(): - raise ValueError("prime must be a prime in the integers but %s is not"%(prime,)) + raise ValueError("prime must be a prime in the integers but %s is not" % (prime,)) return R, prime def create_key_for_local_ring(self, R, prime): @@ -254,7 +254,7 @@ def create_key_and_extra_args_for_number_field_from_valuation(self, R, v, prime, # v is defined on a ring whose field of fractions is L v = v._base_valuation._initial_approximation.change_domain(G.parent()) else: - raise NotImplementedError("cannot rewrite %r which is defined on %r as a pseudo-valuation on %r"%(v, v.domain(), G.parent())) + raise NotImplementedError("cannot rewrite %r which is defined on %r as a pseudo-valuation on %r" % (v, v.domain(), G.parent())) assert(v.domain() is G.parent()) @@ -315,7 +315,7 @@ def create_key_and_extra_args_for_number_field_from_ideal(self, R, I, prime): p = I.relative_norm() F = p.factor() if len(F) != 1: - raise ValueError("%r does not lie over a single prime of %r"%(I, K)) + raise ValueError("%r does not lie over a single prime of %r" % (I, K)) vK = K.valuation(F[0][0]) approximants = vK.mac_lane_approximants(G, require_incomparability=True) @@ -336,7 +336,7 @@ def create_key_and_extra_args_for_number_field_from_ideal(self, R, I, prime): match = [i for (i, v) in enumerate(candidates) if v and all(v(g) > 0 for g in gens)] if len(match) > 1: - raise ValueError("%s does not single out a unique extension of %s to %s"%(prime, vK, L)) + raise ValueError("%s does not single out a unique extension of %s to %s" % (prime, vK, L)) if len(match) == 1: return (R, approximants[match[0]]), {'approximants': approximants} @@ -369,7 +369,7 @@ def _normalize_number_field_data(self, R): elif is_PolynomialQuotientRing(R): from sage.categories.number_fields import NumberFields if R.base_ring().fraction_field() not in NumberFields(): - raise NotImplementedError("cannot normalize quotients over %r"%(R.base_ring(),)) + raise NotImplementedError("cannot normalize quotients over %r" % (R.base_ring(),)) L = R.fraction_field() K = R.base_ring().fraction_field() G = R.modulus().change_ring(K) @@ -397,11 +397,11 @@ def create_object(self, version, key, **extra_args): R = key[0] parent = DiscretePseudoValuationSpace(R) if isinstance(R, pAdicGeneric): - assert(len(key)==1) + assert(len(key) == 1) return parent.__make_element_class__(pAdicValuation_padic)(parent) elif R is ZZ or R is QQ: prime = key[1] - assert(len(key)==2) + assert(len(key) == 2) return parent.__make_element_class__(pAdicValuation_int)(parent, prime) else: v = key[1] @@ -592,7 +592,7 @@ def is_unramified(self, G, include_steps=False, assume_squarefree=False): break next = v.mac_lane_step(G, assume_squarefree=True) - if len(next)>1: + if len(next) > 1: ret = False break steps.append(next[0]) @@ -689,7 +689,7 @@ def is_totally_ramified(self, G, include_steps=False, assume_squarefree=False): break next = v.mac_lane_step(G, assume_squarefree=True) - if len(next)>1: + if len(next) > 1: ret = False break steps.append(next[0]) @@ -828,7 +828,7 @@ def restriction(self, ring): return self if not ring.is_subring(self.domain()): - raise ValueError("ring must be a subring of the domain of this valuation but %r is not a subring of %r"%(ring, self.domain())) + raise ValueError("ring must be a subring of the domain of this valuation but %r is not a subring of %r" % (ring, self.domain())) return pAdicValuation(ring, self.p()) @@ -963,7 +963,7 @@ def element_with_valuation(self, v): from sage.rings.rational_field import QQ v = QQ(v) if v not in self.value_semigroup(): - raise ValueError("%r is not in the value semigroup of %r"%(v, self)) + raise ValueError("%r is not in the value semigroup of %r" % (v, self)) v = ZZ(v * self.domain().absolute_e()) return self.domain().one() << v @@ -977,7 +977,7 @@ def _repr_(self): '3-adic valuation' """ - return "%s-adic valuation"%(self.p()) + return "%s-adic valuation" % (self.p()) def _call_(self, x): r""" @@ -1102,7 +1102,7 @@ def _repr_(self): '3-adic valuation' """ - return "%s-adic valuation"%(self.p()) + return "%s-adic valuation" % (self.p()) def _call_(self, x): """ @@ -1281,7 +1281,7 @@ def simplify(self, x, error=None, force=False, size_heuristic_bound=32): if self._relative_size(rational) < self._relative_size(best): best = rational - assert(self(x-best)>error) + assert(self(x-best) > error) return best diff --git a/src/sage/rings/polynomial/ideal.py b/src/sage/rings/polynomial/ideal.py index a117c7bd663..1ab86736d5b 100644 --- a/src/sage/rings/polynomial/ideal.py +++ b/src/sage/rings/polynomial/ideal.py @@ -54,7 +54,7 @@ def residue_field(self, names=None, check=True): if not self.ring().base_ring().is_finite(): raise TypeError("residue fields only supported for polynomial rings over finite fields.") if not self.is_prime(): - raise ValueError("%s is not a prime ideal"%self) + raise ValueError("%s is not a prime ideal" % self) from sage.rings.finite_rings.residue_field import ResidueField return ResidueField(self, names, check=False) diff --git a/src/sage/rings/polynomial/laurent_polynomial_ring.py b/src/sage/rings/polynomial/laurent_polynomial_ring.py index d922a1a57fc..ac40e815724 100644 --- a/src/sage/rings/polynomial/laurent_polynomial_ring.py +++ b/src/sage/rings/polynomial/laurent_polynomial_ring.py @@ -459,7 +459,7 @@ def _repr_(self): sage: LaurentPolynomialRing(QQ,'x') # indirect doctest Univariate Laurent Polynomial Ring in x over Rational Field """ - return "Univariate Laurent Polynomial Ring in %s over %s"%(self._R.variable_name(), self._R.base_ring()) + return "Univariate Laurent Polynomial Ring in %s over %s" % (self._R.variable_name(), self._R.base_ring()) def _element_constructor_(self, x): """ @@ -607,7 +607,7 @@ def _repr_(self): sage: LaurentPolynomialRing(QQ,1,'x').__repr__() # needs sage.modules 'Multivariate Laurent Polynomial Ring in x over Rational Field' """ - return "Multivariate Laurent Polynomial Ring in %s over %s"%(", ".join(self._R.variable_names()), self._R.base_ring()) + return "Multivariate Laurent Polynomial Ring in %s over %s" % (", ".join(self._R.variable_names()), self._R.base_ring()) def monomial(self, *args): r""" diff --git a/src/sage/rings/polynomial/multi_polynomial_element.py b/src/sage/rings/polynomial/multi_polynomial_element.py index 27b6f577f16..450ba530c92 100644 --- a/src/sage/rings/polynomial/multi_polynomial_element.py +++ b/src/sage/rings/polynomial/multi_polynomial_element.py @@ -114,7 +114,7 @@ def _repr_(self): sage: x + QQbar(sqrt(2) - 1/2*I) # indirect doctest # needs sage.rings.number_field sage.symbolic x + 1.414213562373095? - 0.50000000000000000?*I """ - return "%s"%self.__element + return "%s" % self.__element #################### @@ -1455,7 +1455,7 @@ def subs(self, fixed=None, **kw): variables = list(self.parent().gens()) for i in range(0,len(variables)): if str(variables[i]) in kw: - variables[i]=kw[str(variables[i])] + variables[i] = kw[str(variables[i])] elif fixed and variables[i] in fixed: variables[i] = fixed[variables[i]] return self(tuple(variables)) diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index 28d93c1aa6c..66dd4a6db3d 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -300,7 +300,7 @@ def __call__(self, *args, **kwds): """ R = self._instance.ring() if not R.base_ring().is_field(): - raise ValueError("Coefficient ring must be a field for function '%s'."%(self.f.__name__)) + raise ValueError("Coefficient ring must be a field for function '%s'." % (self.f.__name__)) return self.f(self._instance, *args, **kwds) @@ -367,7 +367,7 @@ def _magma_init_(self, magma): """ P = magma(self.ring()) G = magma(self.gens()) - return 'ideal<%s|%s>'%(P.name(), G._ref()) + return 'ideal<%s|%s>' % (P.name(), G._ref()) @magma_gb_standard_options def _groebner_basis_magma(self, deg_bound=None, prot=False, magma=magma_default): @@ -416,7 +416,7 @@ def _groebner_basis_magma(self, deg_bound=None, prot=False, magma=magma_default) from sage.interfaces.magma import MagmaGBLogPrettyPrinter if prot: - log_parser = MagmaGBLogPrettyPrinter(verbosity=get_verbose()+ 1, style="sage" if prot=="sage" else "magma") + log_parser = MagmaGBLogPrettyPrinter(verbosity=get_verbose() + 1, style="sage" if prot == "sage" else "magma") else: log_parser = None @@ -538,7 +538,7 @@ def _groebner_basis_libsingular(self, algorithm="groebner", *args, **kwds): from sage.libs.singular.function_factory import ff groebner = ff.groebner - if get_verbose()>=2: + if get_verbose() >= 2: opt['prot'] = True for name, value in kwds.items(): if value is not None: @@ -555,7 +555,7 @@ def _groebner_basis_libsingular(self, algorithm="groebner", *args, **kwds): fnc = singular_function(algorithm) S = fnc(self) except NameError: - raise NameError("Algorithm '%s' unknown"%algorithm) + raise NameError("Algorithm '%s' unknown" % algorithm) return S @libsingular_gb_standard_options @@ -1154,7 +1154,7 @@ def triangular_decomposition(self, algorithm=None, singular=singular_default): f = singular_function(algorithm[9:]) Tbar = f(I, attributes={I:{'isSB':1}}) else: - raise TypeError("algorithm '%s' unknown"%algorithm) + raise TypeError("algorithm '%s' unknown" % algorithm) T = Sequence([ MPolynomialIdeal(Q,t) for t in Tbar]) return sorted(T, key=lambda x: x.gens()) @@ -1393,7 +1393,7 @@ def _groebner_basis_ginv(self, algorithm="TQ", criteria='CritPartially', divisio try: im = ginv.MonomInterface(term_order_map[T.name()], st, list(P.variable_names())) except KeyError: - raise NotImplementedError("Term order '%s' not supported by Sage's GINV interface or GINV"%T.term_order()) + raise NotImplementedError("Term order '%s' not supported by Sage's GINV interface or GINV" % T.term_order()) from sage.rings.rational_field import QQ if K is QQ: @@ -1401,7 +1401,7 @@ def _groebner_basis_ginv(self, algorithm="TQ", criteria='CritPartially', divisio elif K.order() <= 2**16 and K.order().is_prime(): ic = ginv.CoeffInterface("ModularShort", st, modularShort=K.order()) else: - raise NotImplementedError("GINV interface for base ring '%s' is not implemented."%K) + raise NotImplementedError("GINV interface for base ring '%s' is not implemented." % K) ip = ginv.PolyInterface("PolyList", st, im, ic) iw = ginv.WrapInterface(criteria, ip) @@ -1519,7 +1519,7 @@ def _groebner_basis_singular_raw(self, algorithm="groebner", singular=singular_d o = _options_py_to_singular.get(o,o) if v: if o in ['degBound','multBound']: - singular.eval(o+'=%d'%v) + singular.eval(o+'=%d' % v) else: singular.option(o) else: @@ -1554,7 +1554,7 @@ def _groebner_basis_singular_raw(self, algorithm="groebner", singular=singular_d elif algorithm == "stdfglm": S = obj.stdfglm() else: - raise TypeError("algorithm '%s' unknown"%algorithm) + raise TypeError("algorithm '%s' unknown" % algorithm) self.__gb_singular = S if prot == "sage": print("") @@ -2140,7 +2140,7 @@ def basis_is_groebner(self, singular=singular_default): M = (F * LTF.syz()).reduce(self._singular_()) for i in range(M.ncols()): - if int(singular.eval("%s[1,%s+1]!=0"%(M.name(),i))): + if int(singular.eval("%s[1,%s+1]!=0" % (M.name(),i))): return False self._singular_().attrib('isSB',1) return True @@ -2821,7 +2821,7 @@ def _variety(T, V, v=None): d = self.dimension() if d > 0: - raise ValueError("The dimension of the ideal is %s, but it should be 0"%d) + raise ValueError("The dimension of the ideal is %s, but it should be 0" % d) if d == -1: return [] @@ -3458,7 +3458,7 @@ def _reduce_using_macaulay2(self, f): """ I = self._macaulay2_() M2 = I.parent() - k = M2('(%r) %% %s'%(f, I.name())) + k = M2('(%r) %% %s' % (f, I.name())) R = self.ring() return R(k) @@ -4716,7 +4716,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal ginv,alg = algorithm.split(":") gb = self._groebner_basis_ginv(algorithm=alg,*args, **kwds) else: - raise NameError("Algorithm '%s' unknown."%algorithm) + raise NameError("Algorithm '%s' unknown." % algorithm) elif algorithm == 'giac:gbasis': from sage.libs.giac import groebner_basis as groebner_basis_libgiac gb = groebner_basis_libgiac(self, prot=prot, *args, **kwds) @@ -4729,7 +4729,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal from . import msolve return msolve.groebner_basis_degrevlex(self, *args, **kwds) else: - raise NameError("Algorithm '%s' unknown."%algorithm) + raise NameError("Algorithm '%s' unknown." % algorithm) gb = sorted(gb, reverse=True) if self.ring().base_ring().is_field(): @@ -5139,7 +5139,7 @@ def degree_of_semi_regularity(self): semi-regular sequences. For more details about semi-regular sequences see [BFS2004]_. """ - degs = [f.degree() for f in self.gens() if f!=0] # we ignore zeroes + degs = [f.degree() for f in self.gens() if f != 0] # we ignore zeroes m, n = self.ngens(), len(set(sum([f.variables() for f in self.gens()],()))) if m <= n: raise ValueError("This function requires an overdefined system of polynomials.") @@ -5238,7 +5238,7 @@ def plot(self, *args, **kwds): V = [(variables[0], None, None), (variables[1], None, None)] if len(args) > 2: - raise TypeError("Expected up to 2 optional parameters but got %d."%len(args)) + raise TypeError("Expected up to 2 optional parameters but got %d." % len(args)) # first check whether user supplied boundaries for e in args: diff --git a/src/sage/rings/polynomial/multi_polynomial_sequence.py b/src/sage/rings/polynomial/multi_polynomial_sequence.py index 1cfabbeda6e..03feaa90ca4 100644 --- a/src/sage/rings/polynomial/multi_polynomial_sequence.py +++ b/src/sage/rings/polynomial/multi_polynomial_sequence.py @@ -316,7 +316,7 @@ def PolynomialSequence(arg1, arg2=None, immutable=False, cr=False, cr_str=None): if arg2: ring = arg2 if not is_ring(ring): - raise TypeError("Ring '%s' not supported."%ring) + raise TypeError("Ring '%s' not supported." % ring) else: try: e = next(iter(gens)) @@ -842,7 +842,7 @@ def _magma_init_(self, magma): """ P = magma(self.ring()).name() v = [x._magma_init_(magma) for x in list(self)] - return 'ideal<%s|%s>'%(P, ','.join(v)) + return 'ideal<%s|%s>' % (P, ','.join(v)) def _repr_(self): """ @@ -870,7 +870,7 @@ def _repr_(self): if len(self) < 20: return Sequence_generic._repr_(self) else: - return "Polynomial Sequence with %d Polynomials in %d Variables"%(len(self),self.nvariables()) + return "Polynomial Sequence with %d Polynomials in %d Variables" % (len(self),self.nvariables()) def __add__(self, right): """ @@ -1417,7 +1417,7 @@ def _groebner_strategy(self): g = GroebnerStrategy(R) for p in self: g.add_as_you_wish(p) - g.reduction_strategy.opt_red_tail=True + g.reduction_strategy.opt_red_tail = True return g def solve(self, algorithm='polybori', n=1, eliminate_linear_variables=True, verbose=False, **kwds): @@ -1620,7 +1620,7 @@ def reduced(self): if isinstance(R, BooleanPolynomialRing_base): from sage.rings.polynomial.pbori.interred import interred as inter_red - l = [p for p in self if not p==0] + l = [p for p in self if not p == 0] l = sorted(inter_red(l, completely=True), reverse=True) return PolynomialSequence(l, R, immutable=True) else: diff --git a/src/sage/rings/polynomial/polynomial_element_generic.py b/src/sage/rings/polynomial/polynomial_element_generic.py index f7b4ba226b9..1f447fc1287 100644 --- a/src/sage/rings/polynomial/polynomial_element_generic.py +++ b/src/sage/rings/polynomial/polynomial_element_generic.py @@ -395,18 +395,18 @@ def _repr(self, name=None): if y.find("-") == 0: y = y[1:] if not atomic_repr and n > 0 and (y.find("+") != -1 or y.find("-") != -1): - x = "(%s)"%x + x = "(%s)" % x if n > 1: - var = "*%s^%s"%(name,n) - elif n==1: - var = "*%s"%name + var = "*%s^%s" % (name,n) + elif n == 1: + var = "*%s" % name else: var = "" - s += "%s%s"%(x,var) + s += "%s%s" % (x,var) s = s.replace(" + -", " - ") s = s.replace(" 1*"," ") s = s.replace(" -1*", " -") - if s==" ": + if s == " ": return "0" return s[1:] @@ -962,22 +962,22 @@ def gcd(self,other,algorithm=None): algorithm = "dense" else: algorithm = "generic" - if algorithm=="dense": + if algorithm == "dense": S = self.parent() # FLINT is faster but a bug makes the conversion extremely slow, # so NTL is used in those cases where the conversion is too slow. Cf # sd = self.degree() od = other.degree() - if max(sd,od)<100 or \ - min(len(self.__coeffs)/sd, len(other.__coeffs)/od)>.06: - implementation="FLINT" + if max(sd,od) < 100 or \ + min(len(self.__coeffs)/sd, len(other.__coeffs)/od) > .06: + implementation = "FLINT" else: - implementation="NTL" + implementation = "NTL" D = PolynomialRing(S.base_ring(),'x',implementation=implementation) g = D(self).gcd(D(other)) return S(g) - elif algorithm=="generic": + elif algorithm == "generic": return Polynomial.gcd(self,other) else: raise ValueError("Unknown algorithm '%s'" % algorithm) @@ -1002,7 +1002,7 @@ def reverse(self, degree=None): if degree is None: degree = self.degree() if not isinstance(degree, (int,Integer)): - raise ValueError("degree argument must be a nonnegative integer, got %s"%degree) + raise ValueError("degree argument must be a nonnegative integer, got %s" % degree) d = {degree-k: v for k,v in self.__coeffs.items() if degree >= k} return self.parent()(d, check=False) @@ -1098,7 +1098,7 @@ def quo_rem(self, other): Q = P.zero() while R.degree() >= B.degree(): aaa = R.leading_coefficient()/B.leading_coefficient() - diff_deg=R.degree()-B.degree() + diff_deg = R.degree()-B.degree() Q += P(aaa).shift(diff_deg) # We know that S*B exactly cancels the leading coefficient of R. # Thus, we skip the computation of this leading coefficient. diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py index 2a6a155b5ae..dcc4d376ffe 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py @@ -548,7 +548,7 @@ def _element_constructor_(self, x): try: return self.element_class(self, self.__ring(x), check=False) except TypeError: - raise TypeError("unable to convert %r to an element of %s"%(x, self)) + raise TypeError("unable to convert %r to an element of %s" % (x, self)) def _coerce_map_from_(self, R): r""" @@ -770,11 +770,11 @@ def _singular_init_(self, S=None): modulus = S(self.modulus()) # should live in Rpoly Rtmp = S(self.polynomial_ring().change_var(self.variable_name())) Rtmp.set_ring() - self.__singular = S("ideal(fetch(%s,%s))"%(Rpoly.name(),modulus.name()),"qring") + self.__singular = S("ideal(fetch(%s,%s))" % (Rpoly.name(),modulus.name()),"qring") return self.__singular def _repr_(self): - return "Univariate Quotient Polynomial Ring in %s over %s with modulus %s"%( + return "Univariate Quotient Polynomial Ring in %s over %s with modulus %s" % ( self.variable_name(), self.base_ring(), self.modulus()) def construction(self): @@ -2127,7 +2127,7 @@ def _isomorphic_ring(self): to_isomorphic_ring = self.hom([isomorphic_ring.gen()]) return from_isomorphic_ring, to_isomorphic_ring, isomorphic_ring - raise NotImplementedError("cannot rewrite %r as an isomorphic ring"%(self,)) + raise NotImplementedError("cannot rewrite %r as an isomorphic ring" % (self,)) def _test_isomorphic_ring(self, **options): r""" diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py index 2f7d825dbf8..4185f0d1455 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py @@ -424,7 +424,7 @@ def __invert__(self): 11 """ if self._polynomial.is_zero(): - raise ZeroDivisionError("element %s of quotient polynomial ring not invertible"%self) + raise ZeroDivisionError("element %s of quotient polynomial ring not invertible" % self) if self._polynomial.is_one(): return self @@ -442,7 +442,7 @@ def __invert__(self): raise NotImplementedError("The base ring (=%s) is not a field" % base) g, _, a = parent.modulus().xgcd(self._polynomial) if g.degree() != 0: - raise ZeroDivisionError("element %s of quotient polynomial ring not invertible"%self) + raise ZeroDivisionError("element %s of quotient polynomial ring not invertible" % self) c = g[0] return self.__class__(self.parent(), (~c)*a, check=False) diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py index 968330c9288..af37b6d9fd7 100644 --- a/src/sage/rings/polynomial/polynomial_ring.py +++ b/src/sage/rings/polynomial/polynomial_ring.py @@ -840,7 +840,7 @@ def _coerce_map_from_(self, P): from sage.rings.polynomial.multi_polynomial_ring import is_MPolynomialRing if is_MPolynomialRing(P) and self.variable_name() in P.variable_names(): P_ = P.remove_var(self.variable_name()) - return self.base_ring()!=P_ and self.base_ring().has_coerce_map_from(P_) + return self.base_ring() != P_ and self.base_ring().has_coerce_map_from(P_) def _magma_init_(self, magma): """ @@ -889,7 +889,7 @@ def _magma_init_(self, magma): """ B = magma(self.base_ring()) Bref = B._ref() - s = 'PolynomialRing(%s)'%(Bref) + s = 'PolynomialRing(%s)' % (Bref) return magma._with_names(s, self.variable_names()) def _gap_init_(self, gap=None): @@ -927,7 +927,7 @@ def _gap_init_(self, gap=None): base_ring = gap(self.base_ring()).name() else: base_ring = self.base_ring()._gap_init_() - return 'PolynomialRing(%s, ["%s"])'%(base_ring, self.variable_name()) + return 'PolynomialRing(%s, ["%s"])' % (base_ring, self.variable_name()) def _sage_input_(self, sib, coerced): r""" @@ -1009,7 +1009,7 @@ def _repr_(self): return self._cached_repr except AttributeError: pass - s = "Univariate Polynomial Ring in %s over %s"%( + s = "Univariate Polynomial Ring in %s over %s" % ( self.variable_name(), self.base_ring()) if self.is_sparse(): s = "Sparse " + s @@ -1024,7 +1024,7 @@ def _latex_(self): sage: latex(S) \Bold{Z}[\alpha_{12}] """ - return "%s[%s]"%(latex.latex(self.base_ring()), self.latex_variable_names()[0]) + return "%s[%s]" % (latex.latex(self.base_ring()), self.latex_variable_names()[0]) def base_extend(self, R): """ @@ -1202,7 +1202,7 @@ def cyclotomic_polynomial(self, n): x - 1 """ if n <= 0: - raise ArithmeticError("n=%s must be positive"%n) + raise ArithmeticError("n=%s must be positive" % n) elif n == 1: return self.gen() - 1 else: @@ -1712,7 +1712,7 @@ class PolynomialRing_commutative(PolynomialRing_general, ring.CommutativeAlgebra def __init__(self, base_ring, name=None, sparse=False, implementation=None, element_class=None, category=None): if base_ring not in _CommutativeRings: - raise TypeError("Base ring %s must be a commutative ring."%repr(base_ring)) + raise TypeError("Base ring %s must be a commutative ring." % repr(base_ring)) # We trust that, if a category is given, that it is useful. if category is None: if base_ring.is_zero(): @@ -2799,7 +2799,7 @@ def alekh_rec(p, k, degree_bound, lvl): - ``degree_bound`` -- the current degree bound - ``lvl`` -- the level in the recursion tree """ - if k<=0: + if k <= 0: return [ (self.zero(),0) ] elif degree_bound < 0: # The only possible root of (current) p, if any, is y = 0 diff --git a/src/sage/rings/polynomial/symmetric_ideal.py b/src/sage/rings/polynomial/symmetric_ideal.py index 84138cd8975..3347cf06f2b 100644 --- a/src/sage/rings/polynomial/symmetric_ideal.py +++ b/src/sage/rings/polynomial/symmetric_ideal.py @@ -210,7 +210,7 @@ def __repr__(self): Symmetric Ideal (x_1^2 + y_2^2, x_2*x_1*y_3 + x_1*y_4) of Infinite polynomial ring in x, y over Rational Field """ - return "Symmetric Ideal %s of %s"%(self._repr_short(), self.ring()) + return "Symmetric Ideal %s of %s" % (self._repr_short(), self.ring()) def _latex_(self): r""" @@ -269,7 +269,7 @@ def __mul__(self, other): """ # determine maximal generator index PARENT = self.ring() - if (not isinstance(other, self.__class__)) or self.ring()!=other.ring(): + if (not isinstance(other, self.__class__)) or self.ring() != other.ring(): if hasattr(other,'gens'): other = SymmetricIdeal(PARENT, other.gens(), coerce=True) other = other.symmetrisation() @@ -355,7 +355,7 @@ def is_maximal(self): if self.is_trivial() and not self.is_zero(): return True V = [p.variables() for p in self.gens()] - V = [x for x in V if len(x)==1] + V = [x for x in V if len(x) == 1] V = [str(x[0]).split('_')[0] for x in V] return set(V) == set(self.ring().variable_names()) @@ -555,11 +555,11 @@ def interreduction(self, tailreduce=True, sorted=False, report=None, RStrat=None if DONE == TODO: break else: - if len(TODO)==len(DONE): + if len(TODO) == len(DONE): import copy bla = copy.copy(TODO) bla.sort() - if bla==DONE: + if bla == DONE: break TODO = DONE return SymmetricIdeal(self.ring(),DONE, coerce=False) @@ -640,7 +640,7 @@ def symmetrisation(self, N=None, tailreduce=False, report=None, use_full_group=F N = max([Y.max_index() for Y in newOUT.gens()]+[1]) else: N = Integer(N) - if hasattr(R,'_max') and R._max %d"%(t.macaulay2_str(), len(t))) + singular_str.append("%s(%d)" % (t.singular_str(), len(t))) + macaulay2_str.append("%s => %d" % (t.macaulay2_str(), len(t))) length += len(t) self._singular_moreblocks += t.singular_moreblocks() @@ -809,8 +809,8 @@ def __init__(self, name='lex', n=0, force=False): block_length = int(block_length) if block_length > 0: # ignore blocks with length 0 blocks.append( TermOrder(block_name, block_length, force=force) ) - singular_str.append("%s(%d)"%(singular_name_mapping.get(block_name, block_name), block_length)) - macaulay2_str.append("%s => %d"%(macaulay2_name_mapping.get(block_name, block_name), block_length)) + singular_str.append("%s(%d)" % (singular_name_mapping.get(block_name, block_name), block_length)) + macaulay2_str.append("%s => %d" % (macaulay2_name_mapping.get(block_name, block_name), block_length)) length += block_length except ValueError: block_name = block.strip() @@ -847,7 +847,7 @@ def __init__(self, name='lex', n=0, force=False): self._name = "matrix" self._singular_str = "M(%s)" % (int_str,) self._macaulay2_str = "" # Macaulay2 does not support matrix term order directly - self._magma_str = '"weight",[%s]'%(int_str,) + self._magma_str = '"weight",[%s]' % (int_str,) from sage.matrix.constructor import matrix self._matrix = matrix(n,name) # defined only for matrix term order @@ -857,7 +857,7 @@ def __init__(self, name='lex', n=0, force=False): raise ValueError("{!r} is not a valid term order".format(name)) if self._length != 0: - self._singular_str = self._singular_str%dict(ngens=self._length) + self._singular_str = self._singular_str % dict(ngens=self._length) if self._name == 'degneglex': self._singular_moreblocks += 1 @@ -1633,19 +1633,19 @@ def _repr_(self): Lexicographic term order """ if self._name == 'matrix': - return 'Matrix term order with matrix\n%s'%(self._matrix,) + return 'Matrix term order with matrix\n%s' % (self._matrix,) elif self._name == 'block': s = [] for t in self._blocks: if not t.is_weighted_degree_order(): - s.append('%s of length %d'%(t,len(t))) + s.append('%s of length %d' % (t,len(t))) else: # includes matrix order - s.append('%s'%(t,)) - return 'Block term order with blocks:\n(%s)'%(',\n '.join(s),) + s.append('%s' % (t,)) + return 'Block term order with blocks:\n(%s)' % (',\n '.join(s),) else: s = print_name_mapping.get(self._name,self._name) + ' term order' if self.is_weighted_degree_order(): - s = s + ' with weights %s'%(self._weights,) + s = s + ' with weights %s' % (self._weights,) return s def singular_str(self): @@ -2244,7 +2244,7 @@ def termorder_from_singular(S): ringorder_column = None weights_one_block = False for idx, block in enumerate(T): - blocktype = singular.eval('%s[1]'%block.name()) + blocktype = singular.eval('%s[1]' % block.name()) if blocktype in ['a']: weights = list(block[2].sage()) weights_one_block = all(w == 1 for w in weights) @@ -2266,7 +2266,7 @@ def termorder_from_singular(S): elif blocktype[0] in ['w','W']: order.append(TermOrder(inv_singular_name_mapping[blocktype], list(block[2].sage()))) else: - order.append(TermOrder(inv_singular_name_mapping[blocktype], ZZ(singular.eval("size(%s[2])"%block.name())))) + order.append(TermOrder(inv_singular_name_mapping[blocktype], ZZ(singular.eval("size(%s[2])" % block.name())))) weights_one_block = False if not order: diff --git a/src/sage/rings/power_series_ring.py b/src/sage/rings/power_series_ring.py index e023867b67e..9b07bfd7594 100644 --- a/src/sage/rings/power_series_ring.py +++ b/src/sage/rings/power_series_ring.py @@ -624,7 +624,7 @@ def _repr_(self): sage: R # optional - sage.rings.finite_rings my power series ring """ - s = "Power Series Ring in %s over %s"%(self.variable_name(), self.base_ring()) + s = "Power Series Ring in %s over %s" % (self.variable_name(), self.base_ring()) if self.is_sparse(): s = 'Sparse ' + s return s @@ -668,7 +668,7 @@ def _latex_(self): sage: latex(R) # optional - sage.rings.finite_rings \Bold{F}_{17}[[y_{12}]] """ - return "%s[[%s]]"%(latex.latex(self.base_ring()), self.latex_variable_names()[0]) + return "%s[[%s]]" % (latex.latex(self.base_ring()), self.latex_variable_names()[0]) def _coerce_map_from_(self, S): """ @@ -693,7 +693,7 @@ def _coerce_map_from_(self, S): if self.base_ring().has_coerce_map_from(S): return True if (is_PolynomialRing(S) or is_PowerSeriesRing(S)) and self.base_ring().has_coerce_map_from(S.base_ring()) \ - and self.variable_names()==S.variable_names(): + and self.variable_names() == S.variable_names(): return True def _element_constructor_(self, f, prec=infinity, check=True): diff --git a/src/sage/rings/quotient_ring.py b/src/sage/rings/quotient_ring.py index 178cae67a22..370759357ba 100644 --- a/src/sage/rings/quotient_ring.py +++ b/src/sage/rings/quotient_ring.py @@ -462,7 +462,7 @@ def __init__(self, R, I, names, category=None): """ if R not in _Rings: - raise TypeError("The first argument must be a ring, but %s is not"%R) + raise TypeError("The first argument must be a ring, but %s is not" % R) # workaround to silence warning from #34806 from sage.rings.number_field.order import Order if isinstance(R, Order): @@ -470,7 +470,7 @@ def __init__(self, R, I, names, category=None): else: M = R.ideal_monoid() if I not in M: - raise TypeError("The second argument must be an ideal of the given ring, but %s is not"%I) + raise TypeError("The second argument must be an ideal of the given ring, but %s is not" % I) self.__R = R self.__I = I #sage.structure.parent_gens.ParentWithGens.__init__(self, R.base_ring(), names) @@ -549,7 +549,7 @@ def _repr_(self): sage: R.quotient_ring(I)._repr_() 'Quotient of Univariate Polynomial Ring in x over Integer Ring by the ideal (x^2 + 3*x + 4, x^2 + 1)' """ - return "Quotient of %s by the ideal %s"%(self.cover_ring(), self.defining_ideal()._repr_short()) + return "Quotient of %s by the ideal %s" % (self.cover_ring(), self.defining_ideal()._repr_short()) def _latex_(self): """ @@ -562,7 +562,7 @@ def _latex_(self): sage: R.quotient_ring(I)._latex_() '\\Bold{Z}[x]/\\left(x^{2} + 3x + 4, x^{2} + 1\\right)\\Bold{Z}[x]' """ - return "%s/%s"%(latex.latex(self.cover_ring()), latex.latex(self.defining_ideal())) + return "%s/%s" % (latex.latex(self.cover_ring()), latex.latex(self.defining_ideal())) def is_commutative(self): """ @@ -1276,7 +1276,7 @@ def _singular_init_(self, singular=None): if singular is None: from sage.interfaces.singular import singular self.__R._singular_().set_ring() - self.__singular = singular("%s"%self.__I._singular_().name(),"qring") + self.__singular = singular("%s" % self.__I._singular_().name(),"qring") return self.__singular def _magma_init_(self, magma): @@ -1304,7 +1304,7 @@ def _magma_init_(self, magma): """ R = magma(self.__R) I = magma(self.__I.gens()) - return "quo<%s|%s>"%(R.name(), I._ref()) + return "quo<%s|%s>" % (R.name(), I._ref()) def term_order(self): """ diff --git a/src/sage/rings/valuation/valuation.py b/src/sage/rings/valuation/valuation.py index c0e78efaf95..ec39b0d98ea 100644 --- a/src/sage/rings/valuation/valuation.py +++ b/src/sage/rings/valuation/valuation.py @@ -911,7 +911,7 @@ def mac_lane_approximant(self, G, valuation, approximants=None): v = valuation while not v.is_gauss_valuation(): if v(G) <= v._base_valuation(G): - raise ValueError("The valuation %r is not an approximant for a valuation which extends %r with respect to %r since the valuation of %r does not increase in every step"%(valuation, self, G, G)) + raise ValueError("The valuation %r is not an approximant for a valuation which extends %r with respect to %r since the valuation of %r does not increase in every step" % (valuation, self, G, G)) v = v._base_valuation if approximants is None: @@ -921,15 +921,15 @@ def mac_lane_approximant(self, G, valuation, approximants=None): greater_approximants = [w for w in approximants if w >= valuation] if len(greater_approximants) > 1: - raise ValueError("The valuation %r does not approximate a unique extension of %r with respect to %r"%(valuation, self, G)) + raise ValueError("The valuation %r does not approximate a unique extension of %r with respect to %r" % (valuation, self, G)) if len(greater_approximants) == 1: return greater_approximants[0] smaller_approximants = [w for w in approximants if w <= valuation] if len(smaller_approximants) > 1: - raise ValueError("The valuation %r is not approximated by a unique extension of %r with respect to %r"%(valuation, self, G)) + raise ValueError("The valuation %r is not approximated by a unique extension of %r with respect to %r" % (valuation, self, G)) if len(smaller_approximants) == 0: - raise ValueError("The valuation %r is not related to an extension of %r with respect to %r"%(valuation, self, G)) + raise ValueError("The valuation %r is not related to an extension of %r with respect to %r" % (valuation, self, G)) return smaller_approximants[0] def montes_factorization(self, G, assume_squarefree=False, required_precision=None): diff --git a/src/sage/rings/valuation/valuation_space.py b/src/sage/rings/valuation/valuation_space.py index 415a1197ed9..be0e9192c7c 100644 --- a/src/sage/rings/valuation/valuation_space.py +++ b/src/sage/rings/valuation/valuation_space.py @@ -486,7 +486,7 @@ def element_with_valuation(self, s): return self.domain().one() exp = s / self.value_group().gen() if exp not in ZZ: - raise NotImplementedError("s must be a multiple of %r but %r is not"%(self.value_group().gen(), s)) + raise NotImplementedError("s must be a multiple of %r but %r is not" % (self.value_group().gen(), s)) ret = self.domain()(self.uniformizer() ** ZZ(exp)) return self.simplify(ret, error=s) @@ -594,7 +594,7 @@ def extension(self, ring): extensions = self.extensions(ring) assert(extensions) if len(extensions) > 1: - raise ValueError("there is no unique extension of %r from %r to %r"%(self, self.domain(), ring)) + raise ValueError("there is no unique extension of %r from %r to %r" % (self, self.domain(), ring)) return extensions[0] def extensions(self, ring): @@ -610,7 +610,7 @@ def extensions(self, ring): """ if ring is self.domain(): return [self] - raise NotImplementedError("extending %r from %r to %r not implemented"%(self, self.domain(), ring)) + raise NotImplementedError("extending %r from %r to %r not implemented" % (self, self.domain(), ring)) def restriction(self, ring): r""" @@ -626,7 +626,7 @@ def restriction(self, ring): """ if ring is self.domain(): return self - raise NotImplementedError("restricting %r from %r to %r not implemented"%(self, self.domain(), ring)) + raise NotImplementedError("restricting %r from %r to %r not implemented" % (self, self.domain(), ring)) def change_domain(self, ring): r""" @@ -649,7 +649,7 @@ def change_domain(self, ring): return self.extension(ring) if ring.is_subring(self.domain()): return self.restriction(ring) - raise NotImplementedError("changing %r from %r to %r not implemented"%(self, self.domain(), ring)) + raise NotImplementedError("changing %r from %r to %r not implemented" % (self, self.domain(), ring)) def scale(self, scalar): r""" @@ -732,11 +732,11 @@ def separating_element(self, others): for other in others + [self]: if other.parent() is not self.parent(): - raise ValueError("all valuations must be valuations on %r but %r is a valuation on %r"%(self.domain(), other, other.domain())) + raise ValueError("all valuations must be valuations on %r but %r is a valuation on %r" % (self.domain(), other, other.domain())) if not other.is_discrete_valuation(): raise ValueError("all valuations must be discrete valuations but %r is not" % (other,)) if other.is_trivial(): - raise ValueError("all valuations must be non-trivial but %r is not"%(other,)) + raise ValueError("all valuations must be non-trivial but %r is not" % (other,)) if len(others) == 0: return self.uniformizer() @@ -882,7 +882,7 @@ def _weakly_separating_element(self, other): ret = self.uniformizer() if self(ret) > other(ret): return ret - raise NotImplementedError("weakly separating element for %r and %r"%(self, other)) + raise NotImplementedError("weakly separating element for %r and %r" % (self, other)) def shift(self, x, s): r""" diff --git a/src/sage/rings/valuation/value_group.py b/src/sage/rings/valuation/value_group.py index 816f142e0c7..57a6c1b2719 100644 --- a/src/sage/rings/valuation/value_group.py +++ b/src/sage/rings/valuation/value_group.py @@ -399,11 +399,11 @@ def _element_with_valuation(self, subgroup, s): """ if s not in self: - raise ValueError("s must be in the value group but %r is not in %r."%(s, self)) + raise ValueError("s must be in the value group but %r is not in %r." % (s, self)) i = self.index(subgroup) x = s/self.gen() - a = x%i + a = x % i if abs(a-i) < a: a -= i b = (x-a)/i @@ -593,7 +593,7 @@ def _repr_(self): """ if self.is_trivial(): return "Trivial Additive Abelian Semigroup" - return "Additive Abelian Semigroup generated by %s"%(', '.join([repr(g) for g in self._generators]),) + return "Additive Abelian Semigroup generated by %s" % (', '.join([repr(g) for g in self._generators]),) def __add__(self, other): r"""