Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
fix E251 in combinat/sf
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Aug 9, 2022
1 parent 12be2d9 commit 6a26dcb
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 97 deletions.
8 changes: 5 additions & 3 deletions src/sage/combinat/crystals/letters.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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.
Expand All @@ -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::
Expand All @@ -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':
Expand Down
9 changes: 4 additions & 5 deletions src/sage/combinat/sf/dual.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/sf/elementary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
39 changes: 22 additions & 17 deletions src/sage/combinat/sf/hall_littlewood.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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``.
Expand Down Expand Up @@ -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)


###########
Expand Down Expand Up @@ -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 #
###########
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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)
Expand Down
42 changes: 25 additions & 17 deletions src/sage/combinat/sf/jack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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``
Expand All @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/sage/combinat/sf/k_dual.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions src/sage/combinat/sf/llt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 6a26dcb

Please sign in to comment.