diff --git a/src/sage/algebras/affine_nil_temperley_lieb.py b/src/sage/algebras/affine_nil_temperley_lieb.py index f7901ae314d..720c5f481cd 100644 --- a/src/sage/algebras/affine_nil_temperley_lieb.py +++ b/src/sage/algebras/affine_nil_temperley_lieb.py @@ -119,7 +119,7 @@ def _repr_(self): sage: A = AffineNilTemperleyLiebTypeA(3); A The affine nilTemperley Lieb algebra A3 over the ring Integer Ring """ - return "The affine nilTemperley Lieb algebra A%s over the ring %s"%(self._n, self._base_ring) + return "The affine nilTemperley Lieb algebra A%s over the ring %s" % (self._n, self._base_ring) def weyl_group(self): """ @@ -234,7 +234,7 @@ def has_no_braid_relation(self, w, i): return False s = w.parent().simple_reflections() wi = w*s[i] - adjacent = [(i-1)%w.parent().n, (i+1)%w.parent().n] + adjacent = [(i-1) % w.parent().n, (i+1) % w.parent().n] for j in adjacent: if j in w.descents(): if j in wi.descents(): @@ -258,6 +258,6 @@ def _repr_term(self, t, short_display=True): if len(redword) == 0: return "1" elif short_display: - return "*".join("%s%d"%(self._prefix, i) for i in redword) + return "*".join("%s%d" % (self._prefix, i) for i in redword) else: - return "*".join("%s[%d]"%(self._prefix, i) for i in redword) + return "*".join("%s[%d]" % (self._prefix, i) for i in redword) diff --git a/src/sage/algebras/cellular_basis.py b/src/sage/algebras/cellular_basis.py index 42ce84307d5..873bd899b3e 100644 --- a/src/sage/algebras/cellular_basis.py +++ b/src/sage/algebras/cellular_basis.py @@ -233,7 +233,7 @@ def _latex_term(self, x): sm = latex(m) if sm.find('\\text{\\textt') != -1: sm = str(m) - return "C^{%s}_{%s}"%(sla, sm) + return "C^{%s}_{%s}" % (sla, sm) def cellular_basis_of(self): """ diff --git a/src/sage/algebras/down_up_algebra.py b/src/sage/algebras/down_up_algebra.py index c5fe5361282..3ee1bcea25f 100644 --- a/src/sage/algebras/down_up_algebra.py +++ b/src/sage/algebras/down_up_algebra.py @@ -237,7 +237,7 @@ def _latex_(self): sage: latex(DU) \mathcal{DU}(a,b,g) """ - return "\\mathcal{DU}(%s,%s,%s)"%(self._alpha, self._beta, self._gamma) + return "\\mathcal{DU}(%s,%s,%s)" % (self._alpha, self._beta, self._gamma) def _repr_term(self, m): r""" diff --git a/src/sage/algebras/free_algebra.py b/src/sage/algebras/free_algebra.py index bcfb0e3a62e..460b623b877 100644 --- a/src/sage/algebras/free_algebra.py +++ b/src/sage/algebras/free_algebra.py @@ -598,7 +598,7 @@ def exp_to_monomial(T): out = [] for i in range(len(T)): if T[i]: - out.append((i%ngens,T[i])) + out.append((i % ngens,T[i])) return M(out) return self.element_class(self, {exp_to_monomial(T):c for T,c in x.letterplace_polynomial().dict().items()}) # ok, not a free algebra element (or should not be viewed as one). diff --git a/src/sage/algebras/fusion_rings/f_matrix.py b/src/sage/algebras/fusion_rings/f_matrix.py index b8ba585b0f4..fe39ebf72b4 100644 --- a/src/sage/algebras/fusion_rings/f_matrix.py +++ b/src/sage/algebras/fusion_rings/f_matrix.py @@ -280,7 +280,7 @@ def __init__(self, fusion_ring, fusion_label="f", var_prefix='fx', inject_variab n_vars = self.findcases() self._poly_ring = PolynomialRing(self._FR.field(), n_vars, var_prefix) if inject_variables: - print("creating variables %s%s..%s%s"%(var_prefix, 1, var_prefix, n_vars)) + print("creating variables %s%s..%s%s" % (var_prefix, 1, var_prefix, n_vars)) self._poly_ring.inject_variables(get_main_globals()) self._idx_to_sextuple, self._fvars = self.findcases(output=True) @@ -309,7 +309,7 @@ def _repr_(self): sage: FusionRing("B2", 1).get_fmatrix() F-Matrix factory for The Fusion Ring of Type B2 and level 1 with Integer Ring coefficients """ - return "F-Matrix factory for %s"%self._FR + return "F-Matrix factory for %s" % self._FR def clear_equations(self): r""" @@ -1600,7 +1600,7 @@ def _triangular_elim(self, eqns=None, verbose=True): n = self.pool._processes chunks = [[] for i in range(n)] for i, eq_tup in enumerate(eqns): - chunks[i%n].append(eq_tup) + chunks[i % n].append(eq_tup) eqns = chunks else: eqns = [eqns] @@ -1680,7 +1680,7 @@ def equations_graph(self, eqns=None): s = [v for v in eq.variables()] for x in s: for y in s: - if y!=x: + if y != x: G.add_edge(x, y) return G diff --git a/src/sage/algebras/fusion_rings/fusion_double.py b/src/sage/algebras/fusion_rings/fusion_double.py index 07c0f55bc97..520ea96ef13 100644 --- a/src/sage/algebras/fusion_rings/fusion_double.py +++ b/src/sage/algebras/fusion_rings/fusion_double.py @@ -198,7 +198,7 @@ def _repr_(self): The Fusion Ring of the Drinfeld Double of Symmetric group of order 3! as a permutation group """ - return "The Fusion Ring of the Drinfeld Double of %s"%self._G + return "The Fusion Ring of the Drinfeld Double of %s" % self._G def inject_variables(self): """ diff --git a/src/sage/algebras/fusion_rings/fusion_ring.py b/src/sage/algebras/fusion_rings/fusion_ring.py index 4cf1e08d0f2..02da0032802 100644 --- a/src/sage/algebras/fusion_rings/fusion_ring.py +++ b/src/sage/algebras/fusion_rings/fusion_ring.py @@ -1180,7 +1180,7 @@ def _get_trees(fr, top_row, root): comp_basis = list() for top in product((a*a).monomials(), repeat=n_strands//2): # If the n_strands is odd, we must extend the top row by a fusing anyon - top_row = list(top)+[a]*(n_strands%2) + top_row = list(top)+[a]*(n_strands % 2) comp_basis.extend(tuple([*top, *levels]) for levels in _get_trees(self, top_row, b)) return comp_basis diff --git a/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py b/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py index 5f21e1049b0..cf1c7a04c39 100644 --- a/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py +++ b/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py @@ -366,7 +366,7 @@ def _latex_(self): sage: latex(H) \mathcal{H}_{5,2}(q) """ - return "\\mathcal{H}_{%s,%s}(%s)"%(self._r, self._n, self._q) + return "\\mathcal{H}_{%s,%s}(%s)" % (self._r, self._n, self._q) def hecke_parameter(self): r""" @@ -479,7 +479,7 @@ def _repr_(self): Ariki-Koike algebra of rank 5 and order 2 with q=q and u=(u0, u1, u2, u3, u4) ... in the LT-basis """ - return "%s in the %s-basis"%(self.realization_of(), self._realization_name()) + return "%s in the %s-basis" % (self.realization_of(), self._realization_name()) def hecke_parameter(self): r""" @@ -602,8 +602,8 @@ def _repr_term(self, m): sage: LT._repr_term( ((1, 0, 2), Permutation([3,2,1])) ) 'L1*L3^2*T[2,1,2]' """ - gen_str = lambda e: '' if e == 1 else '^%s'%e - lhs = '*'.join('L%s'%(j+1) + gen_str(i) + gen_str = lambda e: '' if e == 1 else '^%s' % e + lhs = '*'.join('L%s' % (j+1) + gen_str(i) for j,i in enumerate(m[0]) if i > 0) redword = m[1].reduced_word() if not redword: @@ -625,15 +625,15 @@ def _latex_term(self, m): sage: LT._latex_term( ((1, 0, 2), Permutation([3,2,1])) ) 'L_{1} L_{3}^{2} T_{2} T_{1} T_{2}' """ - gen_str = lambda e: '' if e == 1 else '^{%s}'%e - lhs = ' '.join('L_{%s}'%(j+1) + gen_str(i) + gen_str = lambda e: '' if e == 1 else '^{%s}' % e + lhs = ' '.join('L_{%s}' % (j+1) + gen_str(i) for j,i in enumerate(m[0]) if i > 0) redword = m[1].reduced_word() if not redword: if not lhs: return '1' return lhs - return lhs + ' ' + ' '.join("T_{%d}"%i for i in redword) + return lhs + ' ' + ' '.join("T_{%d}" % i for i in redword) def _from_T_basis(self, t): r""" @@ -698,10 +698,10 @@ def algebra_generators(self): for i in range(self._n): r = list(self._zero_tuple) # Make a copy r[i] = 1 - d['L%s'%(i+1)] = self.monomial( (tuple(r), self._one_perm) ) + d['L%s' % (i+1)] = self.monomial( (tuple(r), self._one_perm) ) G = self._Pn.group_generators() for i in range(1, self._n): - d['T%s'%i] = self.monomial( (self._zero_tuple, G[i]) ) + d['T%s' % i] = self.monomial( (self._zero_tuple, G[i]) ) return Family(sorted(d), lambda i: d[i]) def T(self, i=None): @@ -725,10 +725,10 @@ def T(self, i=None): """ G = self.algebra_generators() if i is None: - return [G['L1']] + [G['T%s'%j] for j in range(1, self._n)] + return [G['L1']] + [G['T%s' % j] for j in range(1, self._n)] if i == 0: return G['L1'] - return G['T%s'%i] + return G['T%s' % i] def L(self, i=None): r""" @@ -759,10 +759,10 @@ def L(self, i=None): if i is None: if self._r == 1: return [self._Li_power(j, 1) for j in range(1, self._n+1)] - return [G['L%s'%j] for j in range(1, self._n+1)] + return [G['L%s' % j] for j in range(1, self._n+1)] if self._r == 1: return self._Li_power(i, 1) - return G['L%s'%i] + return G['L%s' % i] @cached_method def product_on_basis(self, m1, m2): @@ -1179,7 +1179,7 @@ def __init__(self, algebra): sage: TestSuite(T).run() # long time """ _Basis.__init__(self, algebra, prefix='T') - self._assign_names(['T%s'%i for i in range(self._n)]) + self._assign_names(['T%s' % i for i in range(self._n)]) def _repr_term(self, t): r""" @@ -1200,7 +1200,7 @@ def _repr_term(self, t): if len(redword) == 0: return "1" return (self._print_options['prefix'] - + '[%s]'%','.join('%d'%i for i in redword)) + + '[%s]' % ','.join('%d' % i for i in redword)) def _latex_term(self, t): r""" @@ -1220,7 +1220,7 @@ def _latex_term(self, t): redword += t[1].reduced_word() if len(redword) == 0: return "1" - return ''.join("%s_{%d}"%(self._print_options['prefix'], i) + return ''.join("%s_{%d}" % (self._print_options['prefix'], i) for i in redword) def _from_LT_basis(self, m): diff --git a/src/sage/algebras/lie_algebras/classical_lie_algebra.py b/src/sage/algebras/lie_algebras/classical_lie_algebra.py index 26e0153a309..a2bb531abe0 100644 --- a/src/sage/algebras/lie_algebras/classical_lie_algebra.py +++ b/src/sage/algebras/lie_algebras/classical_lie_algebra.py @@ -345,7 +345,7 @@ def set_row(mat, row, val): def build_assoc(row): ret = {} for i, v in row.dict().items(): - ret[i//m, i%m] = v + ret[i//m, i % m] = v return self._assoc(ret) while added: @@ -1124,7 +1124,7 @@ def __init__(self, R, cartan_type): dim = self._classical.dimension() from sage.sets.finite_enumerated_set import FiniteEnumeratedSet index_set = FiniteEnumeratedSet(range(dim)) - names = tuple(['CR%s'%s for s in range(dim)]) + names = tuple(['CR%s' % s for s in range(dim)]) category = LieAlgebras(R).FiniteDimensional().WithBasis() FinitelyGeneratedLieAlgebra.__init__(self, R, names=names, index_set=index_set, diff --git a/src/sage/algebras/lie_algebras/free_lie_algebra.py b/src/sage/algebras/lie_algebras/free_lie_algebra.py index 207f8d63a8c..60d49a174b6 100644 --- a/src/sage/algebras/lie_algebras/free_lie_algebra.py +++ b/src/sage/algebras/lie_algebras/free_lie_algebra.py @@ -713,7 +713,7 @@ def _rewrite_bracket(self, l, r): sage: Lyn([x, [y, [z, x]]]) # indirect doctest [x, [[x, z], y]] """ - assert l < r, "Order mismatch %s > %s"%(l, r) + assert l < r, "Order mismatch %s > %s" % (l, r) if self._is_basis_element(l, r): # Compute the grade of the new element diff --git a/src/sage/algebras/lie_algebras/heisenberg.py b/src/sage/algebras/lie_algebras/heisenberg.py index 629fb0a8306..c75152adb98 100644 --- a/src/sage/algebras/lie_algebras/heisenberg.py +++ b/src/sage/algebras/lie_algebras/heisenberg.py @@ -58,7 +58,7 @@ def p(self, i): sage: L.p(2) p2 """ - return self.element_class(self, {'p%i'%i: self.base_ring().one()}) + return self.element_class(self, {'p%i' % i: self.base_ring().one()}) def q(self, i): """ @@ -70,7 +70,7 @@ def q(self, i): sage: L.q(2) q2 """ - return self.element_class(self, {'q%i'%i: self.base_ring().one()}) + return self.element_class(self, {'q%i' % i: self.base_ring().one()}) def z(self): """ @@ -138,7 +138,7 @@ def _latex_term(self, m): """ if len(m) == 1: return m - return "%s_{%s}"%(m[0], m[1:]) # else it is of length at least 2 + return "%s_{%s}" % (m[0], m[1:]) # else it is of length at least 2 def _unicode_art_term(self, m): r""" @@ -261,12 +261,12 @@ def lie_algebra_generators(self): """ if self._n == 0: return Family(['z'], lambda i: self.z()) - k = ['p%s'%i for i in range(1, self._n+1)] - k += ['q%s'%i for i in range(1, self._n+1)] + k = ['p%s' % i for i in range(1, self._n+1)] + k += ['q%s' % i for i in range(1, self._n+1)] d = {} for i in range(1, self._n+1): - d['p%s'%i] = self.p(i) - d['q%s'%i] = self.q(i) + d['p%s' % i] = self.p(i) + d['q%s' % i] = self.q(i) return Family(k, lambda i: d[i]) @cached_method @@ -282,8 +282,8 @@ def basis(self): """ d = {} for i in range(1, self._n+1): - d['p%s'%i] = self.p(i) - d['q%s'%i] = self.q(i) + d['p%s' % i] = self.p(i) + d['q%s' % i] = self.q(i) d['z'] = self.z() return Family(self._indices, lambda i: d[i]) @@ -385,8 +385,8 @@ def __init__(self, R, n): sage: TestSuite(L).run() """ HeisenbergAlgebra_fd.__init__(self, n) - names = tuple(['p%s'%i for i in range(1,n+1)] - + ['q%s'%i for i in range(1,n+1)] + names = tuple(['p%s' % i for i in range(1,n+1)] + + ['q%s' % i for i in range(1,n+1)] + ['z']) LieAlgebraWithGenerators.__init__(self, R, names=names, index_set=names, category=LieAlgebras(R).Nilpotent().FiniteDimensional().WithBasis()) @@ -687,8 +687,8 @@ def __init__(self, R, n): p = tuple(MS({(0,i): one}) for i in range(1, n+1)) q = tuple(MS({(i,n+1): one}) for i in range(1, n+1)) z = (MS({(0,n+1): one}),) - names = tuple('p%s'%i for i in range(1,n+1)) - names = names + tuple('q%s'%i for i in range(1,n+1)) + ('z',) + names = tuple('p%s' % i for i in range(1,n+1)) + names = names + tuple('q%s' % i for i in range(1,n+1)) + ('z',) cat = LieAlgebras(R).Nilpotent().FiniteDimensional().WithBasis() LieAlgebraFromAssociative.__init__(self, MS, p + q + z, names=names, index_set=names, category=cat) @@ -716,7 +716,7 @@ def p(self, i): [0 0 0] [0 0 0] """ - return self._gens['p%s'%i] + return self._gens['p%s' % i] def q(self, i): r""" @@ -730,7 +730,7 @@ def q(self, i): [0 0 1] [0 0 0] """ - return self._gens['q%s'%i] + return self._gens['q%s' % i] def z(self): """ diff --git a/src/sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py index 31b542cd373..8cc6533b781 100644 --- a/src/sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py @@ -111,7 +111,7 @@ def __init__(self, R, ngens=None, gram_matrix=None, names=None, latex_names = None if (names is None) and (index_set is None): - if ngens==1: + if ngens == 1: names = 'psi' else: names = 'psi_' diff --git a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py index 5c14016eab2..1007488e165 100644 --- a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py @@ -328,10 +328,10 @@ def __classcall_private__(cls, R=None, arg0=None, index_set=None, 'string_quotes', 'sorting_key', 'graded', 'super'] for key in kwds: if key not in known_keywords: - raise ValueError("got an unexpected keyword argument '%s'"%key) + raise ValueError("got an unexpected keyword argument '%s'" % key) if isinstance(arg0,dict) and arg0: - graded=kwds.pop("graded", False) + graded = kwds.pop("graded", False) if weights is not None or graded: from .graded_lie_conformal_algebra import \ GradedLieConformalAlgebra diff --git a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py index a4669506314..7581daf0ddb 100644 --- a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py +++ b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py @@ -152,15 +152,15 @@ def _standardize_s_coeff(s_coeff, index_set, ce, parity=None): #e.g. v = { 0: { (L,2):3, (G,3):1}, 1:{(L,1),2} } v = s_coeff[mypair] key = tuple(mypair) - vals={} + vals = {} for l in v.keys(): lth_product = {k:y for k,y in v[l].items() if y} if lth_product: - vals[l]=lth_product + vals[l] = lth_product myvals = tuple((k, tuple(v.items())) for k, v in vals.items() if v) - if key in sc.keys() and sorted(sc[key]) != sorted(myvals): + if key in sc and sorted(sc[key]) != sorted(myvals): raise ValueError("two distinct values given for one " "and the same bracket, skew-symmetry" "is not satisfied?") @@ -175,25 +175,25 @@ def _standardize_s_coeff(s_coeff, index_set, ce, parity=None): else: parsgn = 1 maxpole = max(v.keys()) - vals={} + vals = {} for k in range(maxpole+1): kth_product = {} for j in range(maxpole+1-k): if k+j in v.keys(): for i in v[k+j]: if (i[0] not in ce) or ( - i[0] in ce and i[1] + j == 0): - kth_product[(i[0],i[1]+j)] = \ - kth_product.get((i[0], i[1]+j), 0) - kth_product[(i[0],i[1]+j)] += parsgn*\ - v[k+j][i]*(-1)**(k+j+1)*binomial(i[1]+j,j) - kth_product = {k:v for k,v in kth_product.items() if v} + i[0] in ce and i[1] + j == 0): + kth_product[(i[0], i[1] + j)] = \ + kth_product.get((i[0], i[1] + j), 0) + kth_product[(i[0], i[1] + j)] += parsgn *\ + v[k+j][i]*(-1)**(k+j+1)*binomial(i[1]+j,j) + kth_product = {k: v for k, v in kth_product.items() if v} if kth_product: - vals[k]=kth_product + vals[k] = kth_product myvals = tuple((k, tuple(v.items())) for k, v in vals.items() if v) - if key in sc.keys() and sorted(sc[key]) != sorted(myvals): + if key in sc and sorted(sc[key]) != sorted(myvals): raise ValueError("two distinct values given for one " "and the same bracket. " "Skew-symmetry is not satisfied?") @@ -214,7 +214,7 @@ def __init__(self, R, s_coeff, index_set=None, central_elements=None, """ names, index_set = standardize_names_index_set(names,index_set) if central_elements is None: - central_elements= tuple() + central_elements = tuple() if names is not None and names != tuple(index_set): names2 = names + tuple(central_elements) @@ -266,14 +266,14 @@ def __init__(self, R, s_coeff, index_set=None, central_elements=None, category = default_category.or_subcategory(category) if element_class is None: - element_class=LCAStructureCoefficientsElement + element_class = LCAStructureCoefficientsElement FinitelyFreelyGeneratedLCA.__init__( self, R, index_set=index_set, central_elements=central_elements, category=category, element_class=element_class, prefix=prefix, names=names, latex_names=latex_names, **kwds) - s_coeff=dict(s_coeff) + s_coeff = dict(s_coeff) self._s_coeff = Family({k: tuple((j, sum(c*self.monomial(i) for i,c in v )) for j,v in s_coeff[k]) for k in s_coeff}) self._parity = dict(zip(self.gens(),parity+(0,)*len(central_elements))) diff --git a/src/sage/algebras/nil_coxeter_algebra.py b/src/sage/algebras/nil_coxeter_algebra.py index 5d255b9786d..862fdc3b97e 100644 --- a/src/sage/algebras/nil_coxeter_algebra.py +++ b/src/sage/algebras/nil_coxeter_algebra.py @@ -110,16 +110,18 @@ def homogeneous_generator_noncommutative_variables(self, r): 0 sage: U.homogeneous_generator_noncommutative_variables(0) 1 - """ - assert (len(self._cartan_type) == 2 and self._cartan_type[0] in ['A','B']) or (len(self._cartan_type) == 3 and self._cartan_type[2] == 1), "Analogue of symmetric functions in noncommutative variables is not defined in type %s"%(self._cartan_type) + ct = self._cartan_type + msg = f"Analogue of symmetric functions in noncommutative variables is not defined in type {ct}" + assert (len(ct) == 2 and ct[0] in ['A', 'B']) or (len(ct) == 3 and ct[2] == 1), msg if r >= self._n: return self.zero() return self.sum_of_monomials(w for w in self._W.pieri_factors() if w.length() == r) - def homogeneous_noncommutative_variables(self,la): + def homogeneous_noncommutative_variables(self, la): r""" Give the homogeneous function indexed by `la`, viewed inside the Nil-Coxeter algebra. + This is only defined in finite type `A`, `B` and affine types `A^{(1)}`, `B^{(1)}`, `C^{(1)}`, `D^{(1)}`. INPUT: @@ -182,9 +184,9 @@ def k_schur_noncommutative_variables(self, la): """ - assert self._cartan_type[0] == 'A' and len(self._cartan_type) == 3 and self._cartan_type[2] == 1, "%s is not affine type A."%(self._W) - assert la in Partitions(), "%s is not a partition."%(la) - assert (len(la) == 0 or la[0] < self._W.n), "%s is not a %s-bounded partition."%(la, self._W.n-1) + assert self._cartan_type[0] == 'A' and len(self._cartan_type) == 3 and self._cartan_type[2] == 1, "%s is not affine type A." % (self._W) + assert la in Partitions(), "%s is not a partition." % (la) + assert (len(la) == 0 or la[0] < self._W.n), "%s is not a %s-bounded partition." % (la, self._W.n-1) Sym = SymmetricFunctions(self._base_ring) h = Sym.homogeneous() ks = Sym.kschur(self._n-1,1) diff --git a/src/sage/algebras/orlik_solomon.py b/src/sage/algebras/orlik_solomon.py index 52dae24fee3..920056787c6 100644 --- a/src/sage/algebras/orlik_solomon.py +++ b/src/sage/algebras/orlik_solomon.py @@ -502,7 +502,7 @@ def as_gca(self): for j in indices: if j != i: mon *= A.gen(j) - rel += sign *mon + rel += sign * mon sign = -sign rels.append(rel) I = A.ideal(rels) diff --git a/src/sage/algebras/quantum_clifford.py b/src/sage/algebras/quantum_clifford.py index 5079283e8ec..2b85615cf20 100644 --- a/src/sage/algebras/quantum_clifford.py +++ b/src/sage/algebras/quantum_clifford.py @@ -288,14 +288,14 @@ def algebra_generators(self): for i in range(self._n): r = list(zero) # Make a copy r[i] = 1 - d['psi%s'%i] = self.monomial( (self._psi(r), one) ) + d['psi%s' % i] = self.monomial((self._psi(r), one)) r[i] = -1 - d['psid%s'%i] = self.monomial( (self._psi(r), one) ) + d['psid%s' % i] = self.monomial((self._psi(r), one)) zero = self._psi(zero) for i in range(self._n): temp = list(zero) # Make a copy temp[i] = 1 - d['w%s'%i] = self.monomial( (zero, tuple(temp)) ) + d['w%s' % i] = self.monomial((zero, tuple(temp))) return Family(sorted(d), lambda i: d[i]) @cached_method @@ -397,10 +397,10 @@ def _repr_term(self, m): 5 """ p, v = m - rp = '*'.join('psi%s'%i if p[i] > 0 else 'psid%s'%i + rp = '*'.join('psi%s' % i if p[i] > 0 else 'psid%s' % i for i in range(self._n) if p[i] != 0) - gen_str = lambda e: '' if e == 1 else '^%s'%e - rv = '*'.join('w%s'%i + gen_str(v[i]) for i in range(self._n) if v[i] != 0) + gen_str = lambda e: '' if e == 1 else '^%s' % e + rv = '*'.join('w%s' % i + gen_str(v[i]) for i in range(self._n) if v[i] != 0) if rp: if rv: return rp + '*' + rv @@ -429,10 +429,10 @@ def _latex_term(self, m): 5 """ p, v = m - rp = ''.join('\\psi_{%s}'%i if p[i] > 0 else '\\psi^{\\dagger}_{%s}'%i + rp = ''.join('\\psi_{%s}' % i if p[i] > 0 else '\\psi^{\\dagger}_{%s}' % i for i in range(self._n) if p[i] != 0) - gen_str = lambda e: '' if e == 1 else '^{%s}'%e - rv = ''.join('\\omega_{%s}'%i + gen_str(v[i]) + gen_str = lambda e: '' if e == 1 else '^{%s}' % e + rv = ''.join('\\omega_{%s}' % i + gen_str(v[i]) for i in range(self._n) if v[i] != 0) if not rp and not rv: return '1' @@ -700,15 +700,15 @@ def _repr_term(self, m): def ppr(i): val = p[i] if val == -1: - return 'psid%s'%i + return 'psid%s' % i elif val == 1: - return 'psi%s'%i + return 'psi%s' % i elif val == 2: - return 'psi%s*psid%s'%(i,i) + return 'psi%s*psid%s' % (i,i) rp = '*'.join(ppr(i) for i in range(self._n) if p[i] != 0) - gen_str = lambda e: '' if e == 1 else '^%s'%e - rv = '*'.join('w%s'%i + gen_str(v[i]) for i in range(self._n) if v[i] != 0) + gen_str = lambda e: '' if e == 1 else '^%s' % e + rv = '*'.join('w%s' % i + gen_str(v[i]) for i in range(self._n) if v[i] != 0) if rp: if rv: return rp + '*' + rv @@ -741,15 +741,15 @@ def _latex_term(self, m): def ppr(i): val = p[i] if val == -1: - return '\\psi^{\\dagger}_{%s}'%i + return '\\psi^{\\dagger}_{%s}' % i elif val == 1: - return '\\psi_{%s}'%i + return '\\psi_{%s}' % i elif val == 2: return '\\psi_{%s}\\psi^{\\dagger}_{%s}' % (i, i) rp = ''.join(ppr(i) for i in range(self._n) if p[i] != 0) - gen_str = lambda e: '' if e == 1 else '^{%s}'%e - rv = ''.join('\\omega_{%s}'%i + gen_str(v[i]) + gen_str = lambda e: '' if e == 1 else '^{%s}' % e + rv = ''.join('\\omega_{%s}' % i + gen_str(v[i]) for i in range(self._n) if v[i] != 0) if not rp and not rv: return '1' @@ -875,7 +875,7 @@ def key(X): return (self._psi(p), tuple(e)) q = self._q - ret = {key(X): (-1)**len(X) * sign * q**(q_power+k*(len(pairings)%2)) + ret = {key(X): (-1)**len(X) * sign * q**(q_power+k*(len(pairings) % 2)) for X in powerset(pairings)} return self._from_dict(ret) diff --git a/src/sage/algebras/splitting_algebra.py b/src/sage/algebras/splitting_algebra.py index 08a4992d48a..3b0dfce4586 100644 --- a/src/sage/algebras/splitting_algebra.py +++ b/src/sage/algebras/splitting_algebra.py @@ -332,10 +332,10 @@ def __init__(self, monic_polynomial, names='X', iterate=True, warning=True): try: cf0_inv = ~(cf[0]) cf0_inv = self(cf0_inv) - verbose("invertible coefficient: %s found" %(cf0_inv)) + verbose("invertible coefficient: %s found" % (cf0_inv)) break except NotImplementedError: - verbose("constant coefficient: %s not invertibe" %(cf0)) + verbose("constant coefficient: %s not invertibe" % (cf0)) # ------------------------------------------------------------------ # assuming that cf splits into linear factors over self diff --git a/src/sage/algebras/steenrod/steenrod_algebra_bases.py b/src/sage/algebras/steenrod/steenrod_algebra_bases.py index f028e6d5df5..c289b284fe1 100644 --- a/src/sage/algebras/steenrod/steenrod_algebra_bases.py +++ b/src/sage/algebras/steenrod/steenrod_algebra_bases.py @@ -834,12 +834,12 @@ def degree_dictionary(n, basis): """ dict = {} if basis.find('wood') >= 0: - k=0 - m=0 + k = 0 + m = 0 deg = 2**m * (2**(k+1) - 1) while deg <= n: dict[deg] = (m,k) - if m>0: + if m > 0: m = m - 1 k = k + 1 else: @@ -847,8 +847,8 @@ def degree_dictionary(n, basis): k = 0 deg = 2**m * (2**(k+1) - 1) elif basis.find('wall') >= 0 or basis.find('arnon') >= 0: - k=0 - m=0 + k = 0 + m = 0 deg = 2**k * (2**(m-k+1) - 1) while deg <= n: dict[deg] = (m,k) @@ -859,8 +859,8 @@ def degree_dictionary(n, basis): k = k - 1 deg = 2**k * (2**(m-k+1) - 1) elif basis.find('pst') >= 0 or basis.find('comm') >= 0: - s=0 - t=1 + s = 0 + t = 1 deg = 2**s * (2**t - 1) while deg <= n: if basis.find('pst') >= 0: @@ -1128,7 +1128,7 @@ def steenrod_basis_error_check(dim, p, **kwds): for i in range(dim): if i % 5 == 0: - verbose("up to dimension %s"%i) + verbose("up to dimension %s" % i) milnor_dim = len(steenrod_algebra_basis.f(i,'milnor',p=p,generic=generic)) for B in bases: if milnor_dim != len(steenrod_algebra_basis.f(i,B,p,generic=generic)): @@ -1147,7 +1147,7 @@ def steenrod_basis_error_check(dim, p, **kwds): for i in range(dim): if i % 5 == 0: - verbose("up to dimension %s"%i) + verbose("up to dimension %s" % i) for pro in profiles: milnor_dim = len(steenrod_algebra_basis.f(i,'milnor',p=p,profile=pro,generic=generic)) for B in bases: diff --git a/src/sage/algebras/steenrod/steenrod_algebra_misc.py b/src/sage/algebras/steenrod/steenrod_algebra_misc.py index d8fedad70b8..91ab657a84f 100644 --- a/src/sage/algebras/steenrod/steenrod_algebra_misc.py +++ b/src/sage/algebras/steenrod/steenrod_algebra_misc.py @@ -177,7 +177,7 @@ def get_basis_name(basis, p, generic=None): if basis.find('long') >= 0: result = result + '_long' else: - gencase = " for the generic Steenrod algebra" if p==2 and generic else "" + gencase = " for the generic Steenrod algebra" if p == 2 and generic else "" raise ValueError("%s is not a recognized basis%s at the prime %s" % (basis, gencase, p)) return result diff --git a/src/sage/algebras/yokonuma_hecke_algebra.py b/src/sage/algebras/yokonuma_hecke_algebra.py index 700395a2d84..df474b8d4f7 100644 --- a/src/sage/algebras/yokonuma_hecke_algebra.py +++ b/src/sage/algebras/yokonuma_hecke_algebra.py @@ -183,7 +183,7 @@ def _latex_(self): sage: latex(Y) \mathcal{Y}_{5,2}(q) """ - return "\\mathcal{Y}_{%s,%s}(%s)"%(self._d, self._n, self._q) + return "\\mathcal{Y}_{%s,%s}(%s)" % (self._d, self._n, self._q) def _repr_term(self, m): """ @@ -195,8 +195,8 @@ def _repr_term(self, m): sage: Y._repr_term( ((1, 0, 2), Permutation([3,2,1])) ) 't1*t3^2*g[2,1,2]' """ - gen_str = lambda e: '' if e == 1 else '^%s'%e - lhs = '*'.join('t%s'%(j+1) + gen_str(i) for j,i in enumerate(m[0]) if i > 0) + gen_str = lambda e: '' if e == 1 else '^%s' % e + lhs = '*'.join('t%s' % (j+1) + gen_str(i) for j,i in enumerate(m[0]) if i > 0) redword = m[1].reduced_word() if not redword: if not lhs: @@ -217,14 +217,14 @@ def _latex_term(self, m): sage: Y._latex_term( ((1, 0, 2), Permutation([3,2,1])) ) 't_{1} t_{3}^2 g_{2} g_{1} g_{2}' """ - gen_str = lambda e: '' if e == 1 else '^%s'%e - lhs = ' '.join('t_{%s}'%(j+1) + gen_str(i) for j,i in enumerate(m[0]) if i > 0) + gen_str = lambda e: '' if e == 1 else '^%s' % e + lhs = ' '.join('t_{%s}' % (j+1) + gen_str(i) for j,i in enumerate(m[0]) if i > 0) redword = m[1].reduced_word() if not redword: if not lhs: return '1' return lhs - return lhs + ' ' + ' '.join("g_{%d}"%i for i in redword) + return lhs + ' ' + ' '.join("g_{%d}" % i for i in redword) @cached_method def algebra_generators(self): @@ -243,10 +243,10 @@ def algebra_generators(self): for i in range(self._n): r = list(zero) # Make a copy r[i] = 1 - d['t%s'%(i+1)] = self.monomial( (tuple(r), one) ) + d['t%s' % (i+1)] = self.monomial( (tuple(r), one) ) G = self._Pn.group_generators() for i in range(1, self._n): - d['g%s'%i] = self.monomial( (tuple(zero), G[i]) ) + d['g%s' % i] = self.monomial( (tuple(zero), G[i]) ) return Family(sorted(d), lambda i: d[i]) @cached_method @@ -323,8 +323,8 @@ def g(self, i=None): """ G = self.algebra_generators() if i is None: - return [G['g%s'%i] for i in range(1, self._n)] - return G['g%s'%i] + return [G['g%s' % i] for i in range(1, self._n)] + return G['g%s' % i] def t(self, i=None): """ @@ -345,8 +345,8 @@ def t(self, i=None): """ G = self.algebra_generators() if i is None: - return [G['t%s'%i] for i in range(1, self._n+1)] - return G['t%s'%i] + return [G['t%s' % i] for i in range(1, self._n+1)] + return G['t%s' % i] def product_on_basis(self, m1, m2): """ @@ -488,7 +488,7 @@ def __invert__(self): if not self: raise ZeroDivisionError if len(self) != 1: - raise NotImplementedError("inverse only implemented for basis elements (monomials in the generators)"%self) + raise NotImplementedError("inverse only implemented for basis elements (monomials in the generators)" % self) H = self.parent() t,w = self.support_of_term() c = ~self.coefficients()[0]