Skip to content

Commit 9aef18a

Browse files
author
Release Manager
committed
Trac #34673: change iterator for ordered set partitions
as suggested by https://gitlab.com/modulispaces/admcycles/-/issues/100 URL: https://trac.sagemath.org/34673 Reported by: chapoton Ticket author(s): Frédéric Chapoton Reviewer(s): Travis Scrimshaw
2 parents 60d884a + 362d8f1 commit 9aef18a

File tree

2 files changed

+256
-123
lines changed

2 files changed

+256
-123
lines changed

src/sage/combinat/chas/wqsym.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,12 @@ def __init__(self, alg, graded=True):
6969
sage: M = algebras.WQSym(QQ).M()
7070
sage: TestSuite(M).run() # long time
7171
"""
72+
def sorting_key(X):
73+
return (sum(map(len, X)), X)
7274
CombinatorialFreeModule.__init__(self, alg.base_ring(),
7375
OrderedSetPartitions(),
7476
category=WQSymBases(alg, graded),
77+
sorting_key=sorting_key,
7578
bracket="", prefix=self._prefix)
7679

7780
def _repr_term(self, osp):
@@ -574,7 +577,7 @@ class Monomial(WQSymBasis_abstract):
574577
sage: M = WQSym.M(); M
575578
Word Quasi-symmetric functions over Rational Field in the Monomial basis
576579
sage: sorted(M.basis(2))
577-
[M[{1, 2}], M[{2}, {1}], M[{1}, {2}]]
580+
[M[{1}, {2}], M[{2}, {1}], M[{1, 2}]]
578581
"""
579582
_prefix = "M"
580583
_basis_name = "Monomial"
@@ -625,6 +628,7 @@ def product_on_basis(self, x, y):
625628

626629
def union(X, Y):
627630
return X.union(Y)
631+
628632
return self.sum_of_monomials(ShuffleProduct_overlapping(x, yshift,
629633
K, union))
630634

@@ -975,12 +979,15 @@ def _C_to_X(self, P):
975979
temp = temp[:j]
976980
break
977981

982+
def union(X, Y):
983+
return X.union(Y)
984+
978985
# Perform the quasi-shuffle product
979986
cur = {data[0]: 1}
980987
for B in data[1:]:
981988
ret = {}
982989
for A in cur:
983-
for C in ShuffleProduct_overlapping(A, B, element_constructor=OSP):
990+
for C in ShuffleProduct_overlapping(A, B, element_constructor=OSP, add=union):
984991
if C in ret:
985992
ret[C] += cur[A]
986993
else:

0 commit comments

Comments
 (0)