From 6a26dcb8ae316ef562ee2caf6269629ac513ecff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 9 Aug 2022 18:37:19 +0200 Subject: [PATCH] fix E251 in combinat/sf --- src/sage/combinat/crystals/letters.pyx | 8 +++-- src/sage/combinat/sf/dual.py | 9 +++--- src/sage/combinat/sf/elementary.py | 2 +- src/sage/combinat/sf/hall_littlewood.py | 39 +++++++++++++---------- src/sage/combinat/sf/jack.py | 42 +++++++++++++++---------- src/sage/combinat/sf/k_dual.py | 8 ++--- src/sage/combinat/sf/llt.py | 16 +++++----- src/sage/combinat/sf/macdonald.py | 33 +++++++++++-------- src/sage/combinat/sf/orthotriang.py | 11 ++++--- src/sage/combinat/sf/sf.py | 9 +++--- src/sage/combinat/sf/sfa.py | 24 +++++++------- src/sage/combinat/sf/witt.py | 20 ++++++------ 12 files changed, 124 insertions(+), 97 deletions(-) diff --git a/src/sage/combinat/crystals/letters.pyx b/src/sage/combinat/crystals/letters.pyx index 8a06939ce07..6ca78aed640 100644 --- a/src/sage/combinat/crystals/letters.pyx +++ b/src/sage/combinat/crystals/letters.pyx @@ -104,7 +104,7 @@ def CrystalOfLetters(cartan_type, element_print_style=None, dual=None): else: return ClassicalCrystalOfLetters(ct, Crystal_of_letters_type_E6_element_dual, - element_print_style, dual = True) + element_print_style, dual=True) elif ct.letter == 'E' and ct.rank() == 7: return ClassicalCrystalOfLetters(ct, Crystal_of_letters_type_E7_element) elif ct.letter == 'E' and ct.rank() == 8 or ct.letter == 'F': @@ -116,6 +116,7 @@ def CrystalOfLetters(cartan_type, element_print_style=None, dual=None): else: raise NotImplementedError + class ClassicalCrystalOfLetters(UniqueRepresentation, Parent): r""" A generic class for classical crystals of letters. @@ -136,7 +137,8 @@ class ClassicalCrystalOfLetters(UniqueRepresentation, Parent): time: ``list``, ``cmp``, (todo: ``phi``, ``epsilon``, ``e``, and ``f`` with caching) """ - def __init__(self, cartan_type, element_class, element_print_style = None, dual = None): + def __init__(self, cartan_type, element_class, + element_print_style=None, dual=None): """ EXAMPLES:: @@ -146,7 +148,7 @@ class ClassicalCrystalOfLetters(UniqueRepresentation, Parent): sage: TestSuite(C).run() """ self.Element = element_class - Parent.__init__(self, category = ClassicalCrystals()) + Parent.__init__(self, category=ClassicalCrystals()) self._cartan_type = CartanType(cartan_type) self.rename("The crystal of letters for type %s" % self._cartan_type) if cartan_type.type() == 'E': diff --git a/src/sage/combinat/sf/dual.py b/src/sage/combinat/sf/dual.py index 4ec49461f59..445521e4193 100644 --- a/src/sage/combinat/sf/dual.py +++ b/src/sage/combinat/sf/dual.py @@ -148,15 +148,14 @@ def __init__(self, dual_basis, scalar, scalar_name="", basis_name=None, prefix=N prefix = 'd_'+dual_basis.prefix() classical.SymmetricFunctionAlgebra_classical.__init__(self, self._sym, - basis_name = basis_name, - prefix = prefix) + basis_name=basis_name, + prefix=prefix) # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = sage.categories.all.ModulesWithBasis(self.base_ring()) - self .register_coercion(SetMorphism(Hom(self._dual_basis, self, category), self._dual_to_self)) + self.register_coercion(SetMorphism(Hom(self._dual_basis, self, category), self._dual_to_self)) self._dual_basis.register_coercion(SetMorphism(Hom(self, self._dual_basis, category), self._self_to_dual)) - def _dual_to_self(self, x): """ Coerce an element of the dual of ``self`` canonically into ``self``. @@ -193,7 +192,7 @@ def _dual_to_self(self, x): sage: h(m([2,1]) + 3*m[1,1,1]) d_m[1, 1, 1] - d_m[2, 1] """ - return self._element_class(self, dual = x) + return self._element_class(self, dual=x) def _self_to_dual(self, x): """ diff --git a/src/sage/combinat/sf/elementary.py b/src/sage/combinat/sf/elementary.py index 5081f4760fe..446acbf23a3 100644 --- a/src/sage/combinat/sf/elementary.py +++ b/src/sage/combinat/sf/elementary.py @@ -67,7 +67,7 @@ def _dual_basis_default(self): sage: e._dual_basis_default() is e.dual_basis() True """ - return self.dual_basis(scalar = None, prefix="f", basis_name = "forgotten") + return self.dual_basis(scalar=None, prefix="f", basis_name="forgotten") def coproduct_on_generators(self, i): r""" diff --git a/src/sage/combinat/sf/hall_littlewood.py b/src/sage/combinat/sf/hall_littlewood.py index 930d3c2b73e..507112d9311 100644 --- a/src/sage/combinat/sf/hall_littlewood.py +++ b/src/sage/combinat/sf/hall_littlewood.py @@ -73,7 +73,7 @@ def __repr__(self): """ return self._name + " over %s" % self._sym.base_ring() - def __init__(self, Sym, t = 't'): + def __init__(self, Sym, t='t'): """ Initialize ``self``. @@ -365,8 +365,8 @@ def __init__(self, hall_littlewood): s = self.__class__.__name__[15:].capitalize() sfa.SymmetricFunctionAlgebra_generic.__init__( self, hall_littlewood._sym, - basis_name = "Hall-Littlewood " + s + hall_littlewood._name_suffix, - prefix = "HL"+s) + basis_name="Hall-Littlewood " + s + hall_littlewood._name_suffix, + prefix="HL" +s) self.t = hall_littlewood.t self._sym = hall_littlewood._sym self._hall_littlewood = hall_littlewood @@ -407,7 +407,8 @@ def _s_to_self(self, x): sage: P(s[2,1]) 6*HLP[1, 1, 1] + HLP[2, 1] """ - return self._from_cache(x, self._s_cache, self._s_to_self_cache, t = self.t) + return self._from_cache(x, self._s_cache, self._s_to_self_cache, + t=self.t) def _self_to_s(self, x): r""" @@ -435,7 +436,8 @@ def _self_to_s(self, x): sage: s(P[2,1]) -6*s[1, 1, 1] + s[2, 1] """ - return self._s._from_cache(x, self._s_cache, self._self_to_s_cache, t = self.t) + return self._s._from_cache(x, self._s_cache, self._self_to_s_cache, + t=self.t) def transition_matrix(self, basis, n): r""" @@ -545,7 +547,7 @@ class Element(sfa.SymmetricFunctionAlgebra_generic.Element): Methods for elements of a Hall-Littlewood basis that are common to all bases. """ - def expand(self, n, alphabet = 'x'): + def expand(self, n, alphabet='x'): r""" Expands the symmetric function as a symmetric polynomial in ``n`` variables. @@ -577,7 +579,7 @@ def expand(self, n, alphabet = 'x'): x^2 """ s = self.parent().realization_of().schur() - return s(self).expand(n, alphabet = alphabet) + return s(self).expand(n, alphabet=alphabet) def scalar(self, x, zee=None): r""" @@ -618,7 +620,7 @@ def scalar(self, x, zee=None): s_x = s(x) return s_self.scalar(s_x, zee) - def scalar_hl(self, x, t = None): + def scalar_hl(self, x, t=None): r""" Returns the Hall-Littlewood (with parameter ``t``) scalar product of ``self`` and ``x``. @@ -661,8 +663,9 @@ def scalar_hl(self, x, t = None): if t is None: t = parent.t p = parent.realization_of().power() - f = lambda part1, part2: part1.centralizer_size(t = t) - return parent._apply_multi_module_morphism(p(self),p(x),f,orthogonal=True) + f = lambda part1, part2: part1.centralizer_size(t=t) + return parent._apply_multi_module_morphism(p(self), p(x), f, + orthogonal=True) ########### @@ -794,12 +797,11 @@ def _s_cache(self, n): sage: l(HLP._s_to_self_cache[2]) [([1, 1], [([1, 1], 1)]), ([2], [([1, 1], t), ([2], 1)])] """ - self._invert_morphism(n, QQt, self._self_to_s_cache, \ - self._s_to_self_cache, to_self_function = self._s_to_self_base, \ + self._invert_morphism(n, QQt, self._self_to_s_cache, + self._s_to_self_cache, to_self_function=self._s_to_self_base, upper_triangular=True, ones_on_diagonal=True) - ########### # Q basis # ########### @@ -844,9 +846,10 @@ def __init__(self, hall_littlewood): # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = sage.categories.all.ModulesWithBasis(self.base_ring()) - phi = self.module_morphism(diagonal = self._P._q_to_p_normalization, codomain = self._P, category = category) + phi = self.module_morphism(diagonal=self._P._q_to_p_normalization, + codomain=self._P, category=category) self._P.register_coercion(phi) - self .register_coercion(~phi) + self.register_coercion(~phi) def _p_to_q_normalization(self, m): r""" @@ -996,10 +999,12 @@ def _s_cache(self, n): sage: l(HLQp._self_to_s_cache[2]) [([1, 1], [([1, 1], 1), ([2], t)]), ([2], [([2], 1)])] """ - self._invert_morphism(n, QQt, self._self_to_s_cache, \ - self._s_to_self_cache, to_other_function = self._to_s, \ + self._invert_morphism(n, QQt, self._self_to_s_cache, + self._s_to_self_cache, + to_other_function=self._to_s, lower_triangular=True, ones_on_diagonal=True) + # Unpickling backward compatibility sage.misc.persist.register_unpickle_override('sage.combinat.sf.hall_littlewood', 'HallLittlewoodElement_p', HallLittlewood_p.Element) sage.misc.persist.register_unpickle_override('sage.combinat.sf.hall_littlewood', 'HallLittlewoodElement_q', HallLittlewood_q.Element) diff --git a/src/sage/combinat/sf/jack.py b/src/sage/combinat/sf/jack.py index 5231e113686..c46c78afefe 100644 --- a/src/sage/combinat/sf/jack.py +++ b/src/sage/combinat/sf/jack.py @@ -503,8 +503,8 @@ def __init__(self, jack): s = self.__class__.__name__[16:].capitalize() sfa.SymmetricFunctionAlgebra_generic.__init__( self, jack._sym, - basis_name = "Jack " + s + jack._name_suffix, - prefix = "Jack"+s) + basis_name="Jack " + s + jack._name_suffix, + prefix="Jack" + s) self.t = jack.t self._sym = jack._sym self._jack = jack @@ -550,7 +550,8 @@ def _m_to_self(self, x): sage: JP(m[2,1]) -3/2*JackP[1, 1, 1] + JackP[2, 1] """ - return self._from_cache(x, self._m_cache, self._m_to_self_cache, t = self.t) + return self._from_cache(x, self._m_cache, self._m_to_self_cache, + t=self.t) def _self_to_m(self, x): r""" @@ -578,7 +579,8 @@ def _self_to_m(self, x): sage: m(JP[2,1]) 3/2*m[1, 1, 1] + m[2, 1] """ - return self._m._from_cache(x, self._m_cache, self._self_to_m_cache, t = self.t) + return self._m._from_cache(x, self._m_cache, self._self_to_m_cache, + t=self.t) def c1(self, part): r""" @@ -897,15 +899,14 @@ def _m_cache(self, n): """ if n in self._self_to_m_cache: return - else: - self._self_to_m_cache[n] = {} + self._self_to_m_cache[n] = {} t = QQt.gen() monomial = sage.combinat.sf.sf.SymmetricFunctions(QQt).monomial() JP = sage.combinat.sf.sf.SymmetricFunctions(QQt).jack().P() - JP._gram_schmidt(n, monomial, lambda p: part_scalar_jack(p,p,t), \ - self._self_to_m_cache[n], upper_triangular=True) - JP._invert_morphism(n, QQt, self._self_to_m_cache, \ - self._m_to_self_cache, to_other_function = self._to_m) + JP._gram_schmidt(n, monomial, lambda p: part_scalar_jack(p, p, t), + self._self_to_m_cache[n], upper_triangular=True) + JP._invert_morphism(n, QQt, self._self_to_m_cache, + self._m_to_self_cache, to_other_function=self._to_m) def _to_m(self, part): r""" @@ -1071,7 +1072,8 @@ def __init__(self, jack): self._P = self._jack.P() # temporary until Hom(GradedHopfAlgebrasWithBasis) works better category = sage.categories.all.ModulesWithBasis(self.base_ring()) - phi = self.module_morphism(diagonal = self.c1, codomain = self._P, category = category) + phi = self.module_morphism(diagonal=self.c1, + codomain=self._P, category=category) # should use module_morphism(on_coeffs = ...) once it exists self._P.register_coercion(self._P._normalize_morphism(category) * phi) self .register_coercion(self ._normalize_morphism(category) *~phi) @@ -1107,15 +1109,19 @@ def __init__(self, jack): self._P = self._jack.P() # temporary until Hom(GradedHopfAlgebrasWithBasis) works better category = sage.categories.all.ModulesWithBasis(self.base_ring()) - phi = self._P.module_morphism(diagonal = self._P.scalar_jack_basis, codomain = self, category = category) - self .register_coercion(self ._normalize_morphism(category) * phi) + phi = self._P.module_morphism(diagonal=self._P.scalar_jack_basis, + codomain=self, category=category) + self.register_coercion(self._normalize_morphism(category) * phi) self._P.register_coercion(self._P._normalize_morphism(category) * ~phi) class Element(JackPolynomials_generic.Element): pass + qp_to_h_cache = {} h_to_qp_cache = {} + + class JackPolynomials_qp(JackPolynomials_generic): def __init__(self, jack): r""" @@ -1247,9 +1253,10 @@ def _self_to_h( self, x ): sage: h(JQp[2,1]) h[2, 1] - 3/5*h[3] """ - return self._h._from_cache(x, self._h_cache, self._self_to_h_cache, t = self.t) + return self._h._from_cache(x, self._h_cache, self._self_to_h_cache, + t=self.t) - def _h_to_self( self, x ): + def _h_to_self(self, x): r""" Isomorphism from the homogeneous basis into ``self`` @@ -1275,9 +1282,10 @@ def _h_to_self( self, x ): sage: JQp(h[2,1]) JackQp[2, 1] + 3/5*JackQp[3] """ - return self._from_cache(x, self._h_cache, self._h_to_self_cache, t = self.t) + return self._from_cache(x, self._h_cache, self._h_to_self_cache, + t=self.t) - def coproduct_by_coercion( self, elt ): + def coproduct_by_coercion(self, elt): r""" Returns the coproduct of the element ``elt`` by coercion to the Schur basis. diff --git a/src/sage/combinat/sf/k_dual.py b/src/sage/combinat/sf/k_dual.py index 7b557b25104..425af1bc96f 100644 --- a/src/sage/combinat/sf/k_dual.py +++ b/src/sage/combinat/sf/k_dual.py @@ -131,7 +131,7 @@ def __init__(self, Sym, k, t='t'): self._quotient_basis = Sym.m() else: self._quotient_basis = Sym.hall_littlewood(t=self.t).P() - Parent.__init__(self, category = GradedHopfAlgebras(R).Quotients().WithRealizations()) + Parent.__init__(self, category=GradedHopfAlgebras(R).Quotients().WithRealizations()) self.indices = ConstantFunction(Partitions_all_bounded(k)) def ambient(self): @@ -282,11 +282,11 @@ def _G_to_km_on_basis_single_level(self, w, m): if m < w.length(): return 0 ans = self.zero() - for la in Partitions(m, max_part = self.k): - ans += g.homogeneous_basis_noncommutative_variables_zero_Hecke((la)).coefficient(w)*mon(la) + for la in Partitions(m, max_part=self.k): + ans += g.homogeneous_basis_noncommutative_variables_zero_Hecke((la)).coefficient(w) * mon(la) return ans - def _AffineGrothendieck(self, w,m): + def _AffineGrothendieck(self, w, m): r""" Returns the affine Grothendieck polynomial indexed by the affine permutation ``w``. Because this belongs to the completion of the algebra, and hence is an diff --git a/src/sage/combinat/sf/llt.py b/src/sage/combinat/sf/llt.py index 3c854f342ed..b6b19659a3e 100644 --- a/src/sage/combinat/sf/llt.py +++ b/src/sage/combinat/sf/llt.py @@ -432,8 +432,8 @@ def __init__(self, llt, prefix): s = self.__class__.__name__[4:] sfa.SymmetricFunctionAlgebra_generic.__init__( self, llt._sym, - basis_name = "level %s LLT "%llt.level() + s + llt._name_suffix, - prefix = prefix) + basis_name="level %s LLT " % llt.level() + s + llt._name_suffix, + prefix=prefix) self.t = llt.t self._sym = llt._sym @@ -474,7 +474,8 @@ def _m_to_self(self, x): sage: HSp3(m[2,1]) -2*HSp3[1, 1, 1] + (2*t^2+2*t+1)*HSp3[2, 1] + (-2*t^2-t)*HSp3[3] """ - return self._from_cache(x, self._m_cache, self._m_to_self_cache, t = self.t) + return self._from_cache(x, self._m_cache, self._m_to_self_cache, + t=self.t) def _self_to_m(self, x): r""" @@ -502,8 +503,8 @@ def _self_to_m(self, x): sage: m(HSp3[2,1]) (t+2)*m[1, 1, 1] + (t+1)*m[2, 1] + t*m[3] """ - return self._m._from_cache(x, self._m_cache, self._self_to_m_cache, t = self.t) - + return self._m._from_cache(x, self._m_cache, self._self_to_m_cache, + t=self.t) def level(self): r""" @@ -598,8 +599,9 @@ def _m_cache(self, n): [([1, 1], [([1, 1], 1/t), ([2], -1/t)]), ([2], [([1, 1], -1/t), ([2], (t + 1)/t)])] """ - self._invert_morphism(n, QQt, self._self_to_m_cache, \ - self._m_to_self_cache, to_other_function = self._to_m) + self._invert_morphism(n, QQt, self._self_to_m_cache, + self._m_to_self_cache, + to_other_function=self._to_m) class Element(sfa.SymmetricFunctionAlgebra_generic.Element): pass diff --git a/src/sage/combinat/sf/macdonald.py b/src/sage/combinat/sf/macdonald.py index 3bc4bdbfd5f..3671ae2de8a 100644 --- a/src/sage/combinat/sf/macdonald.py +++ b/src/sage/combinat/sf/macdonald.py @@ -746,8 +746,8 @@ def __init__(self, macdonald): s = self.__class__.__name__[21:].capitalize() sfa.SymmetricFunctionAlgebra_generic.__init__( self, macdonald._sym, - basis_name = "Macdonald " + s + macdonald._name_suffix, - prefix = "Mcd"+s) + basis_name="Macdonald " + s + macdonald._name_suffix, + prefix="Mcd" + s) self.q = macdonald.q self.t = macdonald.t self._macdonald = macdonald @@ -787,7 +787,8 @@ def _s_to_self(self, x): sage: J(s[2,1]) ((-1/28*q+1/14)/(q-1/4))*McdJ[1, 1, 1] - (1/4/(q-1/4))*McdJ[2, 1] """ - return self._from_cache(x, self._s_cache, self._s_to_self_cache, q = self.q, t = self.t) + return self._from_cache(x, self._s_cache, self._s_to_self_cache, + q=self.q, t=self.t) def _self_to_s(self, x): r""" @@ -815,7 +816,8 @@ def _self_to_s(self, x): sage: s(J[2,1]) (3*q-6)*s[1, 1, 1] + (-4*q+1)*s[2, 1] """ - return self._s._from_cache(x, self._s_cache, self._self_to_s_cache, q = self.q, t = self.t) + return self._s._from_cache(x, self._s_cache, self._self_to_s_cache, + q=self.q, t=self.t) def c1(self, part): r""" @@ -1006,11 +1008,12 @@ def __init__(self, macdonald): self._J = macdonald.J() # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = ModulesWithBasis(self.base_ring()) - phi = self._J.module_morphism(diagonal = self.c2, codomain = self, category = category) + phi = self._J.module_morphism(diagonal=self.c2, + codomain=self, category=category) self.register_coercion( phi) self._J.register_coercion(~phi) - def scalar_qt_basis(self, part1, part2 = None): + def scalar_qt_basis(self, part1, part2=None): r""" Returns the scalar product of `P(part1)` and `P(part2)` This scalar product formula is given in equation (4.11) p.323 @@ -1077,8 +1080,9 @@ def __init__(self, macdonald): # temporary until Hom(GradedHopfAlgebrasWithBasis) works better category = ModulesWithBasis(self.base_ring()) - phi = self._P.module_morphism(diagonal = self._P.scalar_qt_basis, codomain = self, category = category) - self .register_coercion( phi) + phi = self._P.module_morphism(diagonal=self._P.scalar_qt_basis, + codomain=self, category=category) + self.register_coercion( phi) self._P.register_coercion(~phi) class Element(MacdonaldPolynomials_generic.Element): @@ -1134,15 +1138,17 @@ def _s_cache(self, n): [([1, 1], [([1, 1], t^3 - t^2 - t + 1)]), ([2], [([1, 1], -q*t + t^2 + q - t), ([2], q*t^2 - q*t - t + 1)])] """ - self._invert_morphism(n, QQqt, self._self_to_s_cache, \ - self._s_to_self_cache, to_other_function = self._to_s, \ + self._invert_morphism(n, QQqt, self._self_to_s_cache, + self._s_to_self_cache, + to_other_function=self._to_s, upper_triangular=False) def _to_s(self, part): r""" Returns a function which gives the coefficient of a partition in the Schur expansion of self(part). - these computations are completed with coefficients in fraction + + These computations are completed with coefficients in fraction field of polynomials in `q` and `t` INPUT: @@ -1811,8 +1817,9 @@ def _s_cache(self, n): sage: l( S._self_to_s_cache[2] ) [([1, 1], [([1, 1], (-q*t^2 + q*t + t - 1)/(-q^3 + q^2 + q - 1)), ([2], (q*t - t^2 - q + t)/(-q^3 + q^2 + q - 1))]), ([2], [([1, 1], (q*t - t^2 - q + t)/(-q^3 + q^2 + q - 1)), ([2], (-q*t^2 + q*t + t - 1)/(-q^3 + q^2 + q - 1))])] """ - self._invert_morphism(n, QQqt, self._self_to_s_cache, \ - self._s_to_self_cache, to_other_function = self._to_s) + self._invert_morphism(n, QQqt, self._self_to_s_cache, + self._s_to_self_cache, + to_other_function=self._to_s) class Element(MacdonaldPolynomials_generic.Element): diff --git a/src/sage/combinat/sf/orthotriang.py b/src/sage/combinat/sf/orthotriang.py index a0790e4855d..6905cbfd3d9 100644 --- a/src/sage/combinat/sf/orthotriang.py +++ b/src/sage/combinat/sf/orthotriang.py @@ -181,10 +181,13 @@ def _base_cache(self, n): else: self._self_to_base_cache[n] = {} - self._gram_schmidt(n, self._sf_base, self._scalar, self._self_to_base_cache,\ - leading_coeff=self._leading_coeff, upper_triangular=True) - self._invert_morphism(n, self.base_ring(), self._self_to_base_cache, \ - self._base_to_self_cache, to_other_function = self._to_base) + self._gram_schmidt(n, self._sf_base, self._scalar, + self._self_to_base_cache, + leading_coeff=self._leading_coeff, + upper_triangular=True) + self._invert_morphism(n, self.base_ring(), self._self_to_base_cache, + self._base_to_self_cache, + to_other_function=self._to_base) def _to_base(self, part): r""" diff --git a/src/sage/combinat/sf/sf.py b/src/sage/combinat/sf/sf.py index b4418a40606..f18f6fb75a2 100644 --- a/src/sage/combinat/sf/sf.py +++ b/src/sage/combinat/sf/sf.py @@ -1441,15 +1441,16 @@ def __init_extra__(self): for (basis1_name, basis2_name) in conversion_functions: basis1 = getattr(self, basis1_name)() basis2 = getattr(self, basis2_name)() - on_basis = SymmetricaConversionOnBasis(t = conversion_functions[basis1_name,basis2_name], domain = basis1, codomain = basis2) + on_basis = SymmetricaConversionOnBasis(t=conversion_functions[basis1_name,basis2_name], domain=basis1, codomain=basis2) from sage.rings.rational_field import RationalField if basis2_name != "powersum" or self._base.has_coerce_map_from(RationalField()): - iso(basis1._module_morphism(on_basis, codomain = basis2)) + iso(basis1._module_morphism(on_basis, codomain=basis2)) else: # Don't register conversions to powersums as coercions, # unless the base ring is a `\QQ`-algebra # (otherwise the coercion graph loses commutativity). - iso(basis1._module_morphism(on_basis, codomain = basis2), only_conversion = True) + iso(basis1._module_morphism(on_basis, codomain=basis2), + only_conversion=True) # Todo: fill in with other conversion functions on the classical bases @@ -1612,4 +1613,4 @@ def __call__(self, partition): # TODO: use self._codomain.sum_of_monomials, when the later # will have an optional optimization for the case when there # is no repetition in the support - return self._codomain._from_dict(dict(self._t(self.fake_sym.monomial(partition))), coerce = True) + return self._codomain._from_dict(dict(self._t(self.fake_sym.monomial(partition))), coerce=True) diff --git a/src/sage/combinat/sf/sfa.py b/src/sage/combinat/sf/sfa.py index d1fd77e8c69..03ea31525b0 100644 --- a/src/sage/combinat/sf/sfa.py +++ b/src/sage/combinat/sf/sfa.py @@ -2690,8 +2690,7 @@ def _dual_basis_default(self): sage: Sym.f()._dual_basis_default() Symmetric Functions over Rational Field in the elementary basis """ - return self.dual_basis(scalar=zee, scalar_name = "Hall scalar product") - + return self.dual_basis(scalar=zee, scalar_name="Hall scalar product") def dual_basis(self, scalar=None, scalar_name="", basis_name=None, prefix=None): r""" @@ -2750,8 +2749,8 @@ def dual_basis(self, scalar=None, scalar_name="", basis_name=None, prefix=None): scalar = zee scalar_name = "Hall scalar product" return dual.SymmetricFunctionAlgebra_dual(self, scalar, scalar_name, - basis_name = basis_name, - prefix = prefix) + basis_name=basis_name, + prefix=prefix) def basis_name(self): r""" @@ -4579,7 +4578,7 @@ def scalar(self, x, zee=None): p_x = p(x) return sum(zee(mu)*p_x.coefficient(mu)*p_self.coefficient(mu) for mu in p_self.support()) - def scalar_qt(self, x, q = None, t = None): + def scalar_qt(self, x, q=None, t=None): r""" Return the `q,t`-deformed standard Hall-Littlewood scalar product of ``self`` and ``x``. @@ -4633,10 +4632,10 @@ def scalar_qt(self, x, q = None, t = None): q = parent.q else: q = QQ['q','t'].gens()[0] - f = lambda part1, part2: part1.centralizer_size(t = t, q = q) + f = lambda part1, part2: part1.centralizer_size(t=t, q=q) return p._apply_multi_module_morphism(p(self), p(x), f, orthogonal=True) - def scalar_t(self, x, t = None): + def scalar_t(self, x, t=None): r""" Return the `t`-deformed standard Hall-Littlewood scalar product of ``self`` and ``x``. @@ -5155,7 +5154,7 @@ def bernstein_creation_operator(self, n): break return parent(res) - def _expand(self, condition, n, alphabet = 'x'): + def _expand(self, condition, n, alphabet='x'): r""" Expand the symmetric function as a symmetric polynomial in ``n`` variables. @@ -5338,7 +5337,7 @@ def restrict_degree(self, d, exact=True): res = dict(x for x in self._monomial_coefficients.items() if sum(x[0]) <= d) return self.parent()._from_dict(res) - def restrict_partition_lengths(self, l, exact = True): + def restrict_partition_lengths(self, l, exact=True): r""" Return the terms of ``self`` labelled by partitions of length ``l``. @@ -5390,10 +5389,11 @@ def restrict_parts(self, n): sage: z.restrict_parts(1) s[1] + s[1, 1, 1] """ - res = dict(x for x in self._monomial_coefficients.items() if _lmax(x[0]) <= n) + res = dict(x for x in self._monomial_coefficients.items() + if _lmax(x[0]) <= n) return self.parent()._from_dict(res) - def expand(self, n, alphabet = 'x'): + def expand(self, n, alphabet='x'): r""" Expand the symmetric function ``self`` as a symmetric polynomial in ``n`` variables. @@ -5493,7 +5493,7 @@ def skew_by(self, x): if p1.contains(p2)) return parent(s.element_class(s, ret)) - def hl_creation_operator(self, nu, t = None): + def hl_creation_operator(self, nu, t=None): r""" This is the vertex operator that generalizes Jing's operator. diff --git a/src/sage/combinat/sf/witt.py b/src/sage/combinat/sf/witt.py index 169fea1c370..1dadb90ffdf 100644 --- a/src/sage/combinat/sf/witt.py +++ b/src/sage/combinat/sf/witt.py @@ -1022,14 +1022,14 @@ def __init_extra__(self): # the elements of the Witt basis with respect to the powersum basis self._p_inverse_transition_matrices = {} - self .register_coercion(self._p._module_morphism(self._p_to_w_on_basis, codomain = self)) + self .register_coercion(self._p._module_morphism(self._p_to_w_on_basis, codomain=self)) from sage.rings.rational_field import RationalField if self.base_ring().has_coerce_map_from(RationalField): - self._p.register_coercion(self._module_morphism(self._w_to_p_on_basis, codomain = self._p)) + self._p.register_coercion(self._module_morphism(self._w_to_p_on_basis, codomain=self._p)) self._friendly = self._p else: # self._w_to_p_on_basis is a partial map at best - self._p.register_conversion(self._module_morphism(self._w_to_p_on_basis, codomain = self._p)) + self._p.register_conversion(self._module_morphism(self._w_to_p_on_basis, codomain=self._p)) if (not self._coerce_e) and (not self._coerce_h): # ensure that self has coercion at least to one other basis, # or else coercion-based computations will fail @@ -1054,8 +1054,8 @@ def __init_extra__(self): # cache for transition matrices which contain the coordinates of # the elements of the Witt basis with respect to the homogeneous basis self._h_inverse_transition_matrices = {} - self .register_coercion(self._h._module_morphism(self._h_to_w_on_basis, codomain = self)) - self._h.register_coercion(self._module_morphism(self._w_to_h_on_basis, codomain = self._h)) + self .register_coercion(self._h._module_morphism(self._h_to_w_on_basis, codomain=self)) + self._h.register_coercion(self._module_morphism(self._w_to_h_on_basis, codomain=self._h)) if self._friendly is None: self._friendly = self._h @@ -1076,8 +1076,8 @@ def __init_extra__(self): # cache for transition matrices which contain the coordinates of # the elements of the Witt basis with respect to the elementary basis self._e_inverse_transition_matrices = {} - self .register_coercion(self._e._module_morphism(self._e_to_w_on_basis, codomain = self)) - self._e.register_coercion(self._module_morphism(self._w_to_e_on_basis, codomain = self._e)) + self .register_coercion(self._e._module_morphism(self._e_to_w_on_basis, codomain=self)) + self._e.register_coercion(self._module_morphism(self._w_to_e_on_basis, codomain=self._e)) if self._friendly is None: self._friendly = self._e @@ -1337,7 +1337,7 @@ def verschiebung(self, n): w_coords_of_self = self.monomial_coefficients().items() from sage.combinat.partition import Partition dct = {Partition([i // n for i in lam]): coeff - for (lam, coeff) in w_coords_of_self - if all( i % n == 0 for i in lam )} + for lam, coeff in w_coords_of_self + if all(i % n == 0 for i in lam)} result_in_w_basis = parent._from_dict(dct) - return parent(result_in_w_basis) + return result_in_w_basis