Skip to content

Commit 81a23e1

Browse files
author
Release Manager
committed
gh-37218: Fix to ncsym.ncsym.nesting The nesting function in combinat.ncsym.ncsym.py does not operate as described in its documentation. As intended, it should compare all arcs of two set partitions and count the number of times the second arc nests in the first. As written, there was a break statement caused many (necessary) comparisons to be skipped, particularly for set partitions with large blocks. I have re-written the function so that all necessary comparisons are made. I have also added an example in the docstring that was computed incorrectly by the old code, but is corrected by my fix. This bug is not a previously known issue, and I have also confirmed with the original author (@tscrim ) that no one else is currently working on a fix. ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. ### ⌛ Dependencies No dependencies URL: #37218 Reported by: lucasgagnon Reviewer(s): Travis Scrimshaw
2 parents 23586cf + 4e0bcf9 commit 81a23e1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/sage/combinat/ncsym/ncsym.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ def nesting(la, nu):
103103
sage: nesting(set(mu).difference(nu), nu)
104104
1
105105
106+
sage: A = SetPartition([[1], [2,5], [3,4]])
107+
sage: B = SetPartition([[1,3,4], [2,5]])
108+
sage: nesting(A, B)
109+
1
110+
sage: nesting(B, A)
111+
1
112+
106113
::
107114
108115
sage: lst = list(SetPartitions(4))
@@ -135,11 +142,13 @@ def nesting(la, nu):
135142
nst = 0
136143
for p in la:
137144
p = sorted(p)
138-
for i in range(len(p)-1):
139-
for a in arcs:
140-
if a[0] >= p[i]:
145+
for a in arcs:
146+
if p[-1] < a[0]:
147+
continue
148+
for i in range(len(p)-1):
149+
if a[1] <= p[i+1]:
141150
break
142-
if p[i+1] < a[1]:
151+
if a[0] < p[i]:
143152
nst += 1
144153
return nst
145154

0 commit comments

Comments
 (0)