From 2fe6b83898dfa3f7dc40342ef02e294b692b7212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Wed, 4 Sep 2024 14:01:55 +0200 Subject: [PATCH 1/2] pep8 cleanup in algebras --- src/sage/algebras/clifford_algebra.py | 2 +- src/sage/algebras/fusion_rings/fusion_ring.py | 2 +- src/sage/algebras/group_algebra.py | 5 ++- src/sage/algebras/hall_algebra.py | 8 ++-- .../hecke_algebras/ariki_koike_algebra.py | 33 +++++++-------- .../algebras/lie_algebras/bgg_dual_module.py | 2 +- src/sage/algebras/lie_algebras/center_uea.py | 12 +++--- .../lie_algebras/classical_lie_algebra.py | 14 +++---- src/sage/algebras/lie_algebras/onsager.py | 18 ++++----- .../rank_two_heisenberg_virasoro.py | 20 +++++----- .../lie_algebras/symplectic_derivation.py | 10 ++--- .../algebras/lie_algebras/verma_module.py | 2 +- src/sage/algebras/lie_algebras/virasoro.py | 2 +- .../affine_lie_conformal_algebra.py | 2 +- .../free_bosons_lie_conformal_algebra.py | 2 +- .../free_fermions_lie_conformal_algebra.py | 2 +- .../lie_conformal_algebra.py | 5 ++- ..._conformal_algebra_with_structure_coefs.py | 2 +- src/sage/algebras/orlik_solomon.py | 6 +-- src/sage/algebras/orlik_terao.py | 2 +- src/sage/algebras/q_system.py | 4 +- .../algebras/quantum_groups/fock_space.py | 12 +++--- .../quantum_groups/representations.py | 2 +- src/sage/algebras/quantum_oscillator.py | 2 +- .../algebras/rational_cherednik_algebra.py | 40 +++++++++---------- src/sage/algebras/splitting_algebra.py | 6 +-- .../steenrod/steenrod_algebra_mult.py | 8 ++-- src/sage/algebras/tensor_algebra.py | 4 +- src/sage/algebras/yangian.py | 24 +++++------ src/sage/algebras/yokonuma_hecke_algebra.py | 6 +-- 30 files changed, 131 insertions(+), 128 deletions(-) diff --git a/src/sage/algebras/clifford_algebra.py b/src/sage/algebras/clifford_algebra.py index 2fe4a873ec6..92ad6c34d64 100644 --- a/src/sage/algebras/clifford_algebra.py +++ b/src/sage/algebras/clifford_algebra.py @@ -2914,7 +2914,7 @@ def __richcmp__(self, other, op): return contained and contains if op == op_NE: return not (contained and contains) - # remaining case < + # remaining case < return contained and not contains def __mul__(self, other): diff --git a/src/sage/algebras/fusion_rings/fusion_ring.py b/src/sage/algebras/fusion_rings/fusion_ring.py index 1ce6b920daa..56045d2dce6 100644 --- a/src/sage/algebras/fusion_rings/fusion_ring.py +++ b/src/sage/algebras/fusion_rings/fusion_ring.py @@ -1113,7 +1113,7 @@ def is_multiplicity_free(self): return k <= 2 ################################### - ### Braid group representations ### + # Braid group representations # ################################### def get_computational_basis(self, a, b, n_strands): diff --git a/src/sage/algebras/group_algebra.py b/src/sage/algebras/group_algebra.py index eb70b0c699f..8dc952f23b9 100644 --- a/src/sage/algebras/group_algebra.py +++ b/src/sage/algebras/group_algebra.py @@ -222,8 +222,9 @@ def _coerce_map_from_(self, S): hom_G = G.coerce_map_from(S_G) if hom_K is not None and hom_G is not None: return SetMorphism(S.Hom(self, category=self.category() | S.category()), - lambda x: self.sum_of_terms( (hom_G(g), hom_K(c)) for g,c in x )) + lambda x: self.sum_of_terms((hom_G(g), hom_K(c)) for g, c in x)) from sage.misc.persist import register_unpickle_override -register_unpickle_override('sage.algebras.group_algebras', 'GroupAlgebra', GroupAlgebra_class) +register_unpickle_override('sage.algebras.group_algebras', 'GroupAlgebra', + GroupAlgebra_class) diff --git a/src/sage/algebras/hall_algebra.py b/src/sage/algebras/hall_algebra.py index 84bebb13e38..bac7fa4f2fa 100644 --- a/src/sage/algebras/hall_algebra.py +++ b/src/sage/algebras/hall_algebra.py @@ -349,7 +349,7 @@ def coproduct_on_basis(self, la): S = self.tensor_square() if all(x == 1 for x in la): n = len(la) - return S.sum_of_terms([( (Partition([1]*r), Partition([1]*(n-r))), self._q**(-r*(n-r)) ) + return S.sum_of_terms([((Partition([1]*r), Partition([1]*(n-r))), self._q**(-r*(n-r))) for r in range(n+1)], distinct=True) I = HallAlgebraMonomials(self.base_ring(), self._q) @@ -482,9 +482,9 @@ def scalar(self, y): (4*q^2 + 9)/(q^2 - q) """ q = self.parent()._q - f = lambda la: ~( q**(sum(la) + 2*la.weighted_size()) + f = lambda la: ~(q**(sum(la) + 2*la.weighted_size()) * prod(prod((1 - q**-i) for i in range(1,k+1)) - for k in la.to_exp()) ) + for k in la.to_exp())) y = self.parent()(y) ret = q.parent().zero() for mx, cx in self: @@ -687,7 +687,7 @@ def coproduct_on_basis(self, a): + (q^-1)*I[1, 1] # I[1] + I[2] # I[1] + I[2, 1] # I[] """ S = self.tensor_square() - return S.prod(S.sum_of_terms([( (Partition([r]), Partition([n-r]) ), self._q**(-r*(n-r)) ) + return S.prod(S.sum_of_terms([((Partition([r]), Partition([n-r])), self._q**(-r*(n-r))) for r in range(n+1)], distinct=True) for n in a) def antipode_on_basis(self, a): diff --git a/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py b/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py index 3177185c088..8d674d0aaf1 100644 --- a/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py +++ b/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py @@ -738,10 +738,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): @@ -896,9 +896,9 @@ def product_on_basis(self, m1, m2): # combination of standard basis elements using the method and then, # recursively, multiply on the left and right by L1 and T2, # respectively. In other words, we multiply as L1*(T1*L2)*T2. - return ( self.monomial((L1, self._one_perm)) + return (self.monomial((L1, self._one_perm)) * self._product_Tw_L(T1, L2) - * self.monomial((self._zero_tuple, T2)) ) + * self.monomial((self._zero_tuple, T2))) def _product_LTwTv(self, L, w, v): r""" @@ -1023,7 +1023,7 @@ def _product_Tw_L(self, w, L): iaxpy(c, self._product_LTwTv(tuple(L), self._Pn.simple_reflections()[i], v), iL) # need T_i*T_v if a < b: - Ls = [ list(L) for k in range(b-a) ] # make copies of L + Ls = [list(L) for k in range(b-a)] # make copies of L for k in range(b-a): Ls[k][i-1] = a + k Ls[k][i] = b - k @@ -1031,7 +1031,7 @@ def _product_Tw_L(self, w, L): iaxpy(1, {(tuple(l), v): c for l in Ls}, iL) elif a > b: - Ls = [ list(L) for k in range(a-b) ] # make copies of L + Ls = [list(L) for k in range(a-b)] # make copies of L for k in range(a-b): Ls[k][i-1] = b + k Ls[k][i] = a - k @@ -1110,25 +1110,26 @@ def Ltuple(a, b): # return "small" powers of the generators without change if m < self._r: - return self.monomial( (Ltuple(0, m), self._one_perm) ) + return self.monomial((Ltuple(0, m), self._one_perm)) if i > 1: si = self._Pn.simple_reflections()[i-1] qsum = self.base_ring().one() - self._q**-1 # by calling _Li_power we avoid infinite recursion here - return ( self.sum_of_terms( ((Ltuple(c, m-c), si), qsum) for c in range(1, m) ) - + self._q**-1 * self.T(i-1) * self._Li_power(i-1, m) * self.T(i-1) ) + return (self.sum_of_terms(((Ltuple(c, m-c), si), qsum) for c in range(1, m)) + + self._q**-1 * self.T(i-1) * self._Li_power(i-1, m) * self.T(i-1)) # now left with the case i = 1 and m >= r if m > self._r: return self.monomial((Ltuple(0, 1), self._one_perm)) * self._Li_power(i,m-1) z = PolynomialRing(self.base_ring(), 'DUMMY').gen() - p = list(prod(z - val for val in self._u))#[:-1] - p.pop() # remove the highest power + p = list(prod(z - val for val in self._u)) # [:-1] + p.pop() # remove the highest power zero = self.base_ring().zero() return self._from_dict({(Ltuple(0, exp), self._one_perm): -coeff - for exp,coeff in enumerate(p) if coeff != zero}, + for exp, coeff in enumerate(p) + if coeff != zero}, remove_zeros=False, coerce=False) @cached_method @@ -1294,7 +1295,7 @@ def _from_LT_basis(self, m): True """ ret = self.prod(self.L(i+1)**k for i,k in enumerate(m[0])) - return ret * self.monomial( (self._zero_tuple, m[1]) ) + return ret * self.monomial((self._zero_tuple, m[1])) @cached_method def algebra_generators(self): @@ -1337,9 +1338,9 @@ def T(self, i=None): return [self.T(j) for j in range(self._n)] if i == 0: - return self.monomial( ((1,) + self._zero_tuple[1:], self._one_perm) ) + return self.monomial(((1,) + self._zero_tuple[1:], self._one_perm)) s = self._Pn.simple_reflections() - return self.monomial( (self._zero_tuple, s[i]) ) + return self.monomial((self._zero_tuple, s[i])) @cached_method def L(self, i=None): @@ -1514,7 +1515,7 @@ def product_on_basis(self, m1, m2): return L * M * R # The current product of T's and the type A Hecke algebra - tprod = [( [(k, a) for k, a in enumerate(t2) if a != 0], {s2: one} )] + tprod = [([(k, a) for k, a in enumerate(t2) if a != 0], {s2: one})] # s1 through t2 for i in reversed(s1.reduced_word()): diff --git a/src/sage/algebras/lie_algebras/bgg_dual_module.py b/src/sage/algebras/lie_algebras/bgg_dual_module.py index 5f0fa10ddfc..c4e060131da 100644 --- a/src/sage/algebras/lie_algebras/bgg_dual_module.py +++ b/src/sage/algebras/lie_algebras/bgg_dual_module.py @@ -423,7 +423,7 @@ def _acted_upon_(self, scalar, self_on_left=False): ##################################################################### -## Simple modules +# Simple modules # This is an abuse as the monoid is not free. diff --git a/src/sage/algebras/lie_algebras/center_uea.py b/src/sage/algebras/lie_algebras/center_uea.py index c155a797ca5..54057bc9735 100644 --- a/src/sage/algebras/lie_algebras/center_uea.py +++ b/src/sage/algebras/lie_algebras/center_uea.py @@ -6,22 +6,22 @@ - Travis Scrimshaw (2024-01-02): Initial version """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2024 Travis Scrimshaw # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** -#from sage.structure.unique_representation import UniqueRepresentation -#from sage.structure.parent import Parent +# from sage.structure.unique_representation import UniqueRepresentation +# from sage.structure.parent import Parent from sage.combinat.free_module import CombinatorialFreeModule from sage.combinat.integer_lists.invlex import IntegerListsLex from sage.matrix.constructor import matrix -from sage.monoids.indexed_free_monoid import IndexedFreeAbelianMonoid #, IndexedFreeAbelianMonoidElement +from sage.monoids.indexed_free_monoid import IndexedFreeAbelianMonoid from sage.monoids.indexed_free_monoid import IndexedMonoid from sage.combinat.root_system.coxeter_group import CoxeterGroup from sage.combinat.integer_vector_weighted import iterator_fast as intvecwt_iterator diff --git a/src/sage/algebras/lie_algebras/classical_lie_algebra.py b/src/sage/algebras/lie_algebras/classical_lie_algebra.py index ebe892d3436..15badc6881f 100644 --- a/src/sage/algebras/lie_algebras/classical_lie_algebra.py +++ b/src/sage/algebras/lie_algebras/classical_lie_algebra.py @@ -379,15 +379,15 @@ def build_assoc(row): continue basis_pivots.add(p) if self._sparse: - added.append(self.element_class( self, build_assoc(cur_mat[i]) )) + added.append(self.element_class(self, build_assoc(cur_mat[i]))) else: - added.append(self.element_class( self, self._assoc(cur_mat[i].list()) )) + added.append(self.element_class(self, self._assoc(cur_mat[i].list()))) cur_mat = cur_mat.submatrix(nrows=len(pivots)) if self._sparse: - basis = [self.element_class( self, build_assoc(cur_mat[i]) ) + basis = [self.element_class(self, build_assoc(cur_mat[i])) for i in range(cur_mat.rank())] else: - basis = [self.element_class( self, self._assoc(cur_mat[i].list()) ) + basis = [self.element_class(self, self._assoc(cur_mat[i].list())) for i in range(cur_mat.rank())] return Family(basis) @@ -1077,7 +1077,7 @@ def __init__(self, R): ####################################### -## Compact real form +# Compact real form class MatrixCompactRealForm(FinitelyGeneratedLieAlgebra): r""" @@ -1558,7 +1558,7 @@ def monomial_coefficients(self, copy=False): ####################################### -## Chevalley Basis +# Chevalley Basis class LieAlgebraChevalleyBasis(LieAlgebraWithStructureCoefficients): r""" @@ -2054,7 +2054,7 @@ def _weight_action(self, m, wt): # enough in the ambient space to correctly convert things to do # the scalar product. alc = wt.parent().simple_coroots() - return R(wt.scalar( alc[aci[m]] )) + return R(wt.scalar(alc[aci[m]])) def affine(self, kac_moody=True): r""" diff --git a/src/sage/algebras/lie_algebras/onsager.py b/src/sage/algebras/lie_algebras/onsager.py index d4d224ea847..0de70c0a630 100644 --- a/src/sage/algebras/lie_algebras/onsager.py +++ b/src/sage/algebras/lie_algebras/onsager.py @@ -318,7 +318,7 @@ def alternating_central_extension(self): Element = LieAlgebraElement ##################################################################### -## q-Onsager algebra (the quantum group) +# q-Onsager algebra (the quantum group) class QuantumOnsagerAlgebra(CombinatorialFreeModule): @@ -795,10 +795,10 @@ def a(m, p): assert m > 0 terms = q**-2 * self.monomial(B[kr] * B[kl]) terms -= self.monomial(B[1,m]) - temp = ( -sum(q**(-2*(p-1)) * self.monomial(B[1,m-2*p]) + temp = (-sum(q**(-2*(p-1)) * self.monomial(B[1,m-2*p]) for p in range(1, (m - 1) // 2 + 1)) + sum(a(m,p) * self.monomial(B[0,kr[1]-p]) * self.monomial(B[0,p+kl[1]]) - for p in range(1, m // 2 + 1)) ) + for p in range(1, m // 2 + 1))) terms += (q**-2 - 1) * temp else: r = -kr[1] - 1 @@ -812,10 +812,10 @@ def a(m, p): terms -= (q**2-q**-2) * sum(q**(2*(r-1-k)) * self.monomial(B[0,-(k+1)]) * self.monomial(B[0,-r+kl[1]+k]) for k in range(r)) m = -r + kl[1] + 1 - temp = ( -sum(q**(-2*(p-1)) * self.monomial(B[1,m-2*p]) + temp = (-sum(q**(-2*(p-1)) * self.monomial(B[1,m-2*p]) for p in range(1, (m - 1) // 2 + 1)) + sum(a(m,p) * self.monomial(B[0,m-p-1]) * self.monomial(B[0,p-1]) - for p in range(1, m // 2 + 1)) ) + for p in range(1, m // 2 + 1))) terms += (q**-2 - 1) * q**(2*r) * temp else: # [B[rd+a0], B[sd+a1]] r > s @@ -826,10 +826,10 @@ def a(m, p): terms -= (q**2-q**-2) * sum(q**(2*(kl[1]-1-k)) * self.monomial(B[0,-(r-kl[1]+k+1)]) * self.monomial(B[0,k]) for k in range(kl[1])) m = r - kl[1] + 1 - temp = ( -sum(q**(-2*(p-1)) * self.monomial(B[1,m-2*p]) + temp = (-sum(q**(-2*(p-1)) * self.monomial(B[1,m-2*p]) for p in range(1, (m - 1) // 2 + 1)) + sum(a(m,p) * self.monomial(B[0,-p]) * self.monomial(B[0,p-m]) - for p in range(1, m // 2 + 1)) ) + for p in range(1, m // 2 + 1))) terms += (q**-2 - 1) * q**(2*kl[1]) * temp terms = -q**2 * terms elif kl[0] == 1 and kr[0] == 0: @@ -877,7 +877,7 @@ def a(m, p): for h in range(1, ell)) - q**(2*(ell-1)) * self.monomial(B[0,-(p-ell+1)] * B[1,kl[1]-ell]) for ell in range(1, kl[1])) - else: #kl[0] == 0 and kr[0] == 1: + else: # kl[0] == 0 and kr[0] == 1: terms = self.monomial(B[kr] * B[kl]) if kl[1] < kr[1]: # [B[pd+a1], B[md]] with p < m @@ -923,7 +923,7 @@ def a(m, p): return self.monomial(lhs // B[kl]) * terms * self.monomial(rhs // B[kr]) ##################################################################### -## ACE of the Onsager algebra +# ACE of the Onsager algebra class OnsagerAlgebraACE(InfinitelyGeneratedLieAlgebra, IndexedGenerators): diff --git a/src/sage/algebras/lie_algebras/rank_two_heisenberg_virasoro.py b/src/sage/algebras/lie_algebras/rank_two_heisenberg_virasoro.py index 4957ecf7bc9..b3fa2b0c7f4 100644 --- a/src/sage/algebras/lie_algebras/rank_two_heisenberg_virasoro.py +++ b/src/sage/algebras/lie_algebras/rank_two_heisenberg_virasoro.py @@ -211,7 +211,7 @@ def K(self, i=None): """ if i is None: return Family(self._KI, self.K) - return self.monomial( ('K', i) ) + return self.monomial(('K', i)) def t(self, a, b): r""" @@ -225,7 +225,7 @@ def t(self, a, b): """ if a == b == 0: raise ValueError("no t(0, 0) element") - return self.monomial( ('t', self._v(a,b)) ) + return self.monomial(('t', self._v(a,b))) def E(self, a, b): r""" @@ -239,7 +239,7 @@ def E(self, a, b): """ if a == b == 0: raise ValueError("no E(0, 0) element") - return self.monomial( ('E', self._v(a,b)) ) + return self.monomial(('E', self._v(a,b))) def _v(self, a, b): r""" @@ -324,10 +324,10 @@ def _an_element_(self): d = self.monomial v = self._v return ( - d( ('E',v(1,-3)) ) - - self.base_ring().an_element() * d( ('t',v(-1,3)) ) - + d( ('E',v(2,2)) ) - + d( ('K',3) ) + d(('E',v(1,-3))) + - self.base_ring().an_element() * d(('t',v(-1,3))) + + d(('E',v(2,2))) + + d(('K',3)) ) def some_elements(self): @@ -345,9 +345,9 @@ def some_elements(self): """ d = self.monomial v = self._v - return [d( ('E',v(1,1)) ), d( ('E',v(-2,-2)) ), d( ('E',v(0,1)) ), - d( ('t',v(1,1)) ), d( ('t',v(4,-1)) ), d( ('t',v(2,3)) ), - d( ('K',2) ), d( ('K',4) ), self.an_element()] + return [d(('E',v(1,1))), d(('E',v(-2,-2))), d(('E',v(0,1))), + d(('t',v(1,1))), d(('t',v(4,-1))), d(('t',v(2,3))), + d(('K',2)), d(('K',4)), self.an_element()] class Element(LieAlgebraElement): pass diff --git a/src/sage/algebras/lie_algebras/symplectic_derivation.py b/src/sage/algebras/lie_algebras/symplectic_derivation.py index f9a2e483330..af294c4c4b0 100644 --- a/src/sage/algebras/lie_algebras/symplectic_derivation.py +++ b/src/sage/algebras/lie_algebras/symplectic_derivation.py @@ -261,9 +261,9 @@ def _an_element_(self): """ d = self.monomial return ( - d( _Partitions([2,1]) ) - - self.base_ring().an_element() * d( _Partitions([5,2,2,1]) ) - + d( _Partitions([2*self._g-1, self._g+1, 2, 1, 1]) ) + d(_Partitions([2,1])) + - self.base_ring().an_element() * d(_Partitions([5,2,2,1])) + + d(_Partitions([2*self._g-1, self._g+1, 2, 1, 1])) ) def some_elements(self): @@ -279,8 +279,8 @@ def some_elements(self): """ d = self.monomial g = self._g - return [d( _Partitions([2,1]) ), d( _Partitions([g+3,g+1]) ), d( _Partitions([2,1,1])), - d( _Partitions([2*g-1,2*g-2]) ), d( _Partitions([2*g-2,g-1,1]) ), + return [d(_Partitions([2,1])), d(_Partitions([g+3,g+1])), d(_Partitions([2,1,1])), + d(_Partitions([2*g-1,2*g-2])), d(_Partitions([2*g-2,g-1,1])), self.an_element()] class Element(LieAlgebraElement): diff --git a/src/sage/algebras/lie_algebras/verma_module.py b/src/sage/algebras/lie_algebras/verma_module.py index 778a9486707..01320616c5a 100644 --- a/src/sage/algebras/lie_algebras/verma_module.py +++ b/src/sage/algebras/lie_algebras/verma_module.py @@ -843,7 +843,7 @@ def _acted_upon_(self, scalar, self_on_left=False): ##################################################################### -## Morphisms and Homset +# Morphisms and Homset class VermaModuleMorphism(Morphism): diff --git a/src/sage/algebras/lie_algebras/virasoro.py b/src/sage/algebras/lie_algebras/virasoro.py index 0284a10e5e5..961c6fb9bbd 100644 --- a/src/sage/algebras/lie_algebras/virasoro.py +++ b/src/sage/algebras/lie_algebras/virasoro.py @@ -652,7 +652,7 @@ class Element(LieAlgebraElement): pass ##################################################################### -## Representations +# Representations class ChargelessRepresentation(CombinatorialFreeModule): diff --git a/src/sage/algebras/lie_conformal_algebras/affine_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/affine_lie_conformal_algebra.py index a1ccb69653d..e9f697e8257 100644 --- a/src/sage/algebras/lie_conformal_algebras/affine_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/affine_lie_conformal_algebra.py @@ -96,7 +96,7 @@ def __init__(self, R, ct, names=None, prefix=None, bracket=None): ct = CartanType(ct) except IndexError: raise ValueError("ct must be a valid Cartan Type") - if not (ct.is_finite() and ct.is_irreducible ): + if not (ct.is_finite() and ct.is_irreducible): raise ValueError("only affine algebras of simple finite dimensional" "Lie algebras are implemented") hv = Integer(ct.dual_coxeter_number()) diff --git a/src/sage/algebras/lie_conformal_algebras/free_bosons_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/free_bosons_lie_conformal_algebra.py index fe7954e1aea..e66489d49ca 100644 --- a/src/sage/algebras/lie_conformal_algebras/free_bosons_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/free_bosons_lie_conformal_algebra.py @@ -134,7 +134,7 @@ def __init__(self, R, ngens=None, gram_matrix=None, names=None, names,index_set = standardize_names_index_set(names=names, index_set=index_set, ngens=ngens) - bosondict = { (i,j): {1: {('K',0): gram_matrix[index_set.rank(i), + bosondict = {(i,j): {1: {('K',0): gram_matrix[index_set.rank(i), index_set.rank(j)]}} for i in index_set for j in index_set} GradedLieConformalAlgebra.__init__(self,R,bosondict,names=names, 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 4b8cb428f0b..f4723d32372 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 @@ -125,7 +125,7 @@ def __init__(self, R, ngens=None, gram_matrix=None, names=None, names,index_set = standardize_names_index_set(names=names, index_set=index_set, ngens=ngens) - fermiondict = { (i,j): {0: {('K',0): gram_matrix[index_set.rank(i), + fermiondict = {(i,j): {0: {('K',0): gram_matrix[index_set.rank(i), index_set.rank(j)]}} for i in index_set for j in index_set} from sage.rings.rational_field import QQ 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 2631d965307..528a587d795 100644 --- a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py @@ -308,8 +308,9 @@ class LieConformalAlgebra(UniqueRepresentation, Parent): """ @staticmethod def __classcall_private__(cls, R=None, arg0=None, index_set=None, - central_elements=None, category=None, prefix=None, - names=None, latex_names=None, parity=None, weights=None, **kwds): + central_elements=None, category=None, + prefix=None, names=None, latex_names=None, + parity=None, weights=None, **kwds): """ Lie conformal algebra factory. 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 4fe54a98963..3cb8f645cd5 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 @@ -275,7 +275,7 @@ def __init__(self, R, s_coeff, index_set=None, central_elements=None, 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}) + 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))) def structure_coefficients(self): diff --git a/src/sage/algebras/orlik_solomon.py b/src/sage/algebras/orlik_solomon.py index 7302b430738..113bb29418f 100644 --- a/src/sage/algebras/orlik_solomon.py +++ b/src/sage/algebras/orlik_solomon.py @@ -791,9 +791,9 @@ def action(g, m): # computing the invariant will be a block matrix. To avoid dealing # with huge matrices, we can split it up into graded pieces. - max_deg = max([b.degree() for b in OS.basis()]) - B = [] #initialize the basis - for d in range(max_deg+1): + max_deg = max(b.degree() for b in OS.basis()) + B = [] # initialize the basis + for d in range(max_deg + 1): OS_d = OS.homogeneous_component(d) OSG_d = OS_d.invariant_module(G, action=action, category=category) B += [OS_d.lift(OSG_d.lift(b)) for b in OSG_d.basis()] diff --git a/src/sage/algebras/orlik_terao.py b/src/sage/algebras/orlik_terao.py index 707b7f51060..60c3c60e6db 100644 --- a/src/sage/algebras/orlik_terao.py +++ b/src/sage/algebras/orlik_terao.py @@ -292,7 +292,7 @@ def degree_on_basis(self, m): """ return len(m) - ## Multiplication + # Multiplication def product_on_basis(self, a, b): r""" diff --git a/src/sage/algebras/q_system.py b/src/sage/algebras/q_system.py index cea0332d4f4..a8342434847 100644 --- a/src/sage/algebras/q_system.py +++ b/src/sage/algebras/q_system.py @@ -446,12 +446,12 @@ def Q(self, a, m): if m == t[a] * self._level: return self.one() if m == 1: - return self.monomial( self._indices.gen((a,1)) ) + return self.monomial(self._indices.gen((a,1))) #if self._cartan_type.type() == 'A' and self._level is None: # return self._jacobi_trudy(a, m) I = self._cm.index_set() p = self._Q_poly(a, m) - return p.subs({ g: self.Q(I[i], 1) for i,g in enumerate(self._poly.gens()) }) + return p.subs({g: self.Q(I[i], 1) for i,g in enumerate(self._poly.gens())}) @cached_method def _Q_poly(self, a, m): diff --git a/src/sage/algebras/quantum_groups/fock_space.py b/src/sage/algebras/quantum_groups/fock_space.py index 8a7ce3e9386..d1d98d3c184 100644 --- a/src/sage/algebras/quantum_groups/fock_space.py +++ b/src/sage/algebras/quantum_groups/fock_space.py @@ -749,7 +749,7 @@ def N_left(la, x, i): return (sum(1 for y in P._addable(la, i) if P._above(x, y)) - sum(1 for y in P._removable(la, i) if P._above(x, y))) q = P.realization_of()._q - return P.sum_of_terms(( la.remove_cell(*x), c * q**(-N_left(la, x, i)) ) + return P.sum_of_terms((la.remove_cell(*x), c * q**(-N_left(la, x, i))) for la,c in self for x in P._removable(la, i)) def e(self, *data): @@ -845,8 +845,8 @@ def N_right(la, x, i): return (sum(1 for y in P._addable(la, i) if P._above(y, x)) - sum(1 for y in P._removable(la, i) if P._above(y, x))) q = P.realization_of()._q - return P.sum_of_terms( (la.add_cell(*x), c * q**N_right(la, x, i)) - for la,c in self for x in P._addable(la, i) ) + return P.sum_of_terms((la.add_cell(*x), c * q**N_right(la, x, i)) + for la,c in self for x in P._addable(la, i)) def f(self, *data): r""" @@ -1384,7 +1384,7 @@ def _G_to_fock_basis(self, la): ############################################################################### -## Bases Category +# Bases Category class FockSpaceBases(Category_realization_of_parent): r""" @@ -1605,7 +1605,7 @@ def __getitem__(self, i): return self.monomial(i) ############################################################################### -## Truncated Fock space +# Truncated Fock space class FockSpaceTruncated(FockSpace): @@ -2178,7 +2178,7 @@ def _G_to_fock_basis(self, la, algorithm='GW'): mu = _Partitions([p - x for p in la]) def add_cols(nu): - return _Partitions([ v + x for v in list(nu) + [0]*(k - len(nu)) ]) + return _Partitions([v + x for v in list(nu) + [0]*(k - len(nu))]) return fock.sum_of_terms((add_cols(nu), c) for nu,c in self._G_to_fock_basis(mu)) # For critical partitions diff --git a/src/sage/algebras/quantum_groups/representations.py b/src/sage/algebras/quantum_groups/representations.py index 7042c5aba76..7d42aa78787 100644 --- a/src/sage/algebras/quantum_groups/representations.py +++ b/src/sage/algebras/quantum_groups/representations.py @@ -124,7 +124,7 @@ def K_on_basis(self, i, b, power=1): """ WLR = self.basis().keys().weight_lattice_realization() alc = WLR.simple_coroots() - return self.term( b, self._q**(b.weight().scalar(alc[i]) * self._d[i] * power) ) + return self.term(b, self._q**(b.weight().scalar(alc[i]) * self._d[i] * power)) class CyclicRepresentation(QuantumGroupRepresentation): diff --git a/src/sage/algebras/quantum_oscillator.py b/src/sage/algebras/quantum_oscillator.py index a688283705f..7ac3509238f 100644 --- a/src/sage/algebras/quantum_oscillator.py +++ b/src/sage/algebras/quantum_oscillator.py @@ -122,7 +122,7 @@ class QuantumOscillatorAlgebra(CombinatorialFreeModule): - [Kuniba2022]_ Section 3.2 """ @staticmethod - def __classcall_private__(cls, q=None, R=None): + def __classcall_private__(cls, q=None, R=None): r""" Standardize input to ensure a unique representation. diff --git a/src/sage/algebras/rational_cherednik_algebra.py b/src/sage/algebras/rational_cherednik_algebra.py index 58b3ce5441d..c3ff9ff25e6 100644 --- a/src/sage/algebras/rational_cherednik_algebra.py +++ b/src/sage/algebras/rational_cherednik_algebra.py @@ -245,19 +245,19 @@ def algebra_generators(self): def gen_map(k): if k[0] == 's': i = int(k[1:]) - return self.monomial( (self._hd.one(), + return self.monomial((self._hd.one(), self._weyl.group_generators()[i], - self._h.one()) ) + self._h.one())) if k[1] == 'c': i = int(k[2:]) - return self.monomial( (self._hd.one(), + return self.monomial((self._hd.one(), self._weyl.one(), - self._h.monoid_generators()[i]) ) + self._h.monoid_generators()[i])) i = int(k[1:]) - return self.monomial( (self._hd.monoid_generators()[i], + return self.monomial((self._hd.monoid_generators()[i], self._weyl.one(), - self._h.one()) ) + self._h.one())) return Family(keys, gen_map) @cached_method @@ -351,16 +351,16 @@ def commute_w_hd(w, al): # al is given as a dictionary del dr[ir] # We now commute right roots past the left reflections: s Ra = Ra' s - cur = self._from_dict({ (hd, s*right[1], right[2]): c * cc + cur = self._from_dict({(hd, s*right[1], right[2]): c * cc for s,c in terms - for hd, cc in commute_w_hd(s, dr) }) - cur = self.monomial( (left[0], left[1], self._h(dl)) ) * cur + for hd, cc in commute_w_hd(s, dr)}) + cur = self.monomial((left[0], left[1], self._h(dl))) * cur # Add back in the commuted h and hd elements - rem = self.monomial( (left[0], left[1], self._h(dl)) ) - rem = rem * self.monomial( (self._hd({ir:1}), self._weyl.one(), - self._h({il:1})) ) - rem = rem * self.monomial( (self._hd(dr), right[1], right[2]) ) + rem = self.monomial((left[0], left[1], self._h(dl))) + rem = rem * self.monomial((self._hd({ir:1}), self._weyl.one(), + self._h({il:1}))) + rem = rem * self.monomial((self._hd(dr), right[1], right[2])) return cur + rem @@ -376,17 +376,17 @@ def commute_w_hd(w, al): # al is given as a dictionary ret *= x**dl[k] ret = ret.dict() w = left[1]*right[1] - return self._from_dict({ (left[0], w, + return self._from_dict({(left[0], w, self._h({I[i]: e for i,e in enumerate(k) if e != 0}) * right[2] ): ret[k] - for k in ret }) + for k in ret}) # Otherwise dr is non-trivial and we have La Ls Ra Rs Rac, # so we must commute Ls Ra = Ra' Ls w = left[1]*right[1] - return self._from_dict({ (left[0] * hd, w, right[2]): c - for hd, c in commute_w_hd(left[1], dr) }) + return self._from_dict({(left[0] * hd, w, right[2]): c + for hd, c in commute_w_hd(left[1], dr)}) @cached_method def _product_coroot_root(self, i, j): @@ -429,12 +429,12 @@ def _product_coroot_root(self, i, j): al = Q.simple_root(j) R = self.base_ring() - terms = [( self._weyl.one(), self._t * R(ac.scalar(al)) )] + terms = [(self._weyl.one(), self._t * R(ac.scalar(al)))] for s in self._reflections: # p[0] is the root, p[1] is the coroot, p[2] the value c_s pr, pc, c = self._reflections[s] - terms.append(( s, c * R(ac.scalar(pr) * pc.scalar(al) - / pc.scalar(pr)) )) + terms.append((s, c * R(ac.scalar(pr) * pc.scalar(al) + / pc.scalar(pr)))) return tuple(terms) def degree_on_basis(self, m): diff --git a/src/sage/algebras/splitting_algebra.py b/src/sage/algebras/splitting_algebra.py index 6fe2880d825..cfcb86e5c28 100644 --- a/src/sage/algebras/splitting_algebra.py +++ b/src/sage/algebras/splitting_algebra.py @@ -349,10 +349,10 @@ def __init__(self, monic_polynomial, names='X', iterate=True, warning=True): if not check.is_zero(): continue root_inv = self.one() - for pos in range(deg_cf-1 ): - root_inv = (-1 )**(pos+1 ) * cf[deg_cf-pos-1 ] - root_inv * root + for pos in range(deg_cf-1): + root_inv = (-1)**(pos+1) * cf[deg_cf-pos-1] - root_inv * root verbose("inverse %s of root %s" % (root_inv, root)) - root_inv = (-1 )**(deg_cf) * cf0_inv * root_inv + root_inv = (-1)**(deg_cf) * cf0_inv * root_inv self._invertible_elements.update({root:root_inv}) verbose("adding inverse %s of root %s" % (root_inv, root)) invert_items = list(self._invertible_elements.items()) diff --git a/src/sage/algebras/steenrod/steenrod_algebra_mult.py b/src/sage/algebras/steenrod/steenrod_algebra_mult.py index c087bb65ba4..053290bc5ed 100644 --- a/src/sage/algebras/steenrod/steenrod_algebra_mult.py +++ b/src/sage/algebras/steenrod/steenrod_algebra_mult.py @@ -312,9 +312,9 @@ def milnor_multiplication(r,s): else: sum = sum + M[i][j] * 2**j else: - sum = sum + M[i][j] * 2**j - j = j + 1 - i = i + 1 + sum = sum + M[i][j] * 2**j + j += 1 + i += 1 return result @@ -784,7 +784,7 @@ def adem(a, b, c=0, p=2, generic=None): return result # p odd if a == 0 and b == 0: - return {(c,): 1} + return {(c,): 1} if c == 0: bockstein = 0 A = a diff --git a/src/sage/algebras/tensor_algebra.py b/src/sage/algebras/tensor_algebra.py index 0d323a6ebb7..3a5f8d9c033 100644 --- a/src/sage/algebras/tensor_algebra.py +++ b/src/sage/algebras/tensor_algebra.py @@ -583,7 +583,7 @@ def coproduct_on_basis(self, m): # for w in Word(range(p)).shuffle(range(p, k)) ) ##################################################################### -## TensorAlgebra functor +# TensorAlgebra functor class TensorAlgebraFunctor(ConstructionFunctor): @@ -684,7 +684,7 @@ def _apply_functor_to_morphism(self, f): return D.module_morphism(phi, codomain=C) ##################################################################### -## Lift map from the base ring +# Lift map from the base ring class BaseRingLift(Morphism): diff --git a/src/sage/algebras/yangian.py b/src/sage/algebras/yangian.py index b17a1de0554..748586a30b9 100644 --- a/src/sage/algebras/yangian.py +++ b/src/sage/algebras/yangian.py @@ -575,13 +575,13 @@ def product_on_gens(self, a, b): # This is the special term of x = 1 x1 = self.zero() if b[1] == a[2]: - x1 += self.monomial( I.gen((a[0]+b[0]-1, a[1], b[2])) ) + x1 += self.monomial(I.gen((a[0]+b[0]-1, a[1], b[2]))) if a[1] == b[2]: - x1 -= self.monomial( I.gen((a[0]+b[0]-1, b[1], a[2])) ) + x1 -= self.monomial(I.gen((a[0]+b[0]-1, b[1], a[2]))) return self.monomial(I.gen(b) * I.gen(a)) + x1 + self.sum( - self.monomial( I.gen((x-1, b[1], a[2])) * I.gen((a[0]+b[0]-x, a[1], b[2])) ) - - self.product_on_gens( (a[0]+b[0]-x, b[1], a[2]), (x-1, a[1], b[2]) ) + self.monomial(I.gen((x-1, b[1], a[2])) * I.gen((a[0]+b[0]-x, a[1], b[2]))) + - self.product_on_gens((a[0]+b[0]-x, b[1], a[2]), (x-1, a[1], b[2])) for x in range(2, b[0]+1)) def coproduct_on_basis(self, m): @@ -610,9 +610,9 @@ def coproduct_on_basis(self, m): """ T = self.tensor_square() I = self._indices - return T.prod(T.monomial( (I.one(), I.gen((a[0],a[1],a[2]))) ) - + T.monomial( (I.gen((a[0],a[1],a[2])), I.one()) ) - + T.sum_of_terms([(( I.gen((s,a[1],k)), I.gen((a[0]-s,k,a[2])) ), 1) + return T.prod(T.monomial((I.one(), I.gen((a[0],a[1],a[2])))) + + T.monomial((I.gen((a[0],a[1],a[2])), I.one())) + + T.sum_of_terms([((I.gen((s,a[1],k)), I.gen((a[0]-s,k,a[2]))), 1) for k in range(1, self._n+1) for s in range(1, a[0])]) for a,exp in m._sorted_items() for p in range(exp)) @@ -881,12 +881,12 @@ def product_on_gens(self, a, b): x1 = self.zero() if a[0]+b[0]-1 <= self._level: if b[1] == a[2]: - x1 += self.monomial( I.gen((a[0]+b[0]-1, a[1], b[2])) ) + x1 += self.monomial(I.gen((a[0]+b[0]-1, a[1], b[2]))) if a[1] == b[2]: - x1 -= self.monomial( I.gen((a[0]+b[0]-1, b[1], a[2])) ) + x1 -= self.monomial(I.gen((a[0]+b[0]-1, b[1], a[2]))) return self.monomial(I.gen(b) * I.gen(a)) + x1 + self.sum( - self.monomial( I.gen((x-1, b[1], a[2])) * I.gen((a[0]+b[0]-x, a[1], b[2])) ) + self.monomial(I.gen((x-1, b[1], a[2])) * I.gen((a[0]+b[0]-x, a[1], b[2]))) - self.product_on_gens((a[0]+b[0]-x, b[1], a[2]), (x-1, a[1], b[2])) for x in range(2, b[0]+1) if a[0]+b[0]-x <= self._level) @@ -1043,8 +1043,8 @@ def antipode_on_basis(self, m): + 10*tbar(1)[1,2]*tbar(1)[1,3]^3*tbar(3)[1,2] + 15*tbar(1)[1,2]^2*tbar(1)[1,3]^2*tbar(3)[1,3] """ - return self.prod( (-1)**exp * self.monomial(a**exp) - for a,exp in reversed(list(m)) ) + return self.prod((-1)**exp * self.monomial(a**exp) + for a,exp in reversed(list(m))) def coproduct_on_basis(self, m): """ diff --git a/src/sage/algebras/yokonuma_hecke_algebra.py b/src/sage/algebras/yokonuma_hecke_algebra.py index 8f366ff3401..7de8ff07798 100644 --- a/src/sage/algebras/yokonuma_hecke_algebra.py +++ b/src/sage/algebras/yokonuma_hecke_algebra.py @@ -245,10 +245,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 @@ -494,5 +494,5 @@ def __invert__(self): H = self.parent() t,w = self.support_of_term() c = ~self.coefficients()[0] - telt = H.monomial( (tuple((H._d - e) % H._d for e in t), H._Pn.one()) ) + telt = H.monomial((tuple((H._d - e) % H._d for e in t), H._Pn.one())) return c * telt * H.prod(H.inverse_g(i) for i in reversed(w.reduced_word())) From e712c07a081465eda6e410874dfd8b06c5387aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Wed, 4 Sep 2024 15:49:18 +0200 Subject: [PATCH 2/2] Update src/sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py Co-authored-by: gmou3 <32706872+gmou3@users.noreply.github.com> --- .../free_fermions_lie_conformal_algebra.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f4723d32372..40810602ac4 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 @@ -125,7 +125,7 @@ def __init__(self, R, ngens=None, gram_matrix=None, names=None, names,index_set = standardize_names_index_set(names=names, index_set=index_set, ngens=ngens) - fermiondict = {(i,j): {0: {('K',0): gram_matrix[index_set.rank(i), + fermiondict = {(i,j): {0: {('K', 0): gram_matrix[index_set.rank(i), index_set.rank(j)]}} for i in index_set for j in index_set} from sage.rings.rational_field import QQ