Skip to content

Commit

Permalink
sagemathgh-36182: fix E228 and E225 in algebras/
Browse files Browse the repository at this point in the history
    
mostly about space before and after modulo

### 📝 Checklist

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
    
URL: sagemath#36182
Reported by: Frédéric Chapoton
Reviewer(s): David Coudert
  • Loading branch information
Release Manager committed Sep 4, 2023
2 parents fe15431 + 78b34d2 commit 740fccc
Show file tree
Hide file tree
Showing 21 changed files with 118 additions and 116 deletions.
8 changes: 4 additions & 4 deletions src/sage/algebras/affine_nil_temperley_lieb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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():
Expand All @@ -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)
2 changes: 1 addition & 1 deletion src/sage/algebras/cellular_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/down_up_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/free_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
8 changes: 4 additions & 4 deletions src/sage/algebras/fusion_rings/f_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/fusion_rings/fusion_double.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/fusion_rings/fusion_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 16 additions & 16 deletions src/sage/algebras/hecke_algebras/ariki_koike_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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:
Expand All @@ -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"""
Expand Down Expand Up @@ -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):
Expand All @@ -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"""
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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"""
Expand All @@ -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"""
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/algebras/lie_algebras/classical_lie_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/lie_algebras/free_lie_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions src/sage/algebras/lie_algebras/heisenberg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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):
"""
Expand Down Expand Up @@ -155,7 +155,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"""
Expand Down Expand Up @@ -278,12 +278,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
Expand All @@ -299,8 +299,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])

Expand Down Expand Up @@ -402,8 +402,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())
Expand Down Expand Up @@ -704,8 +704,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)
Expand Down Expand Up @@ -733,7 +733,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"""
Expand All @@ -747,7 +747,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):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 740fccc

Please sign in to comment.