Skip to content

Commit 5933a29

Browse files
committed
fix bug in fusiontree iterator
1 parent 00eb107 commit 5933a29

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/fusiontrees/iterator.jl

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,21 +198,26 @@ function _fusiontree_iterate(uncoupledsectors::NTuple{N}, coupled::I, out, lines
198198
vertexiterN = c dual(b)
199199
outstateN = states[end]
200200
vertexstateN = states[end - 1]
201+
n = vertices[end]
201202
while isnothing(rest)
202-
n = vertices[end]
203-
n < Nsymbol(a, b, c) && return out, lines, (restvertices..., n + 1), states
204-
nextline = iterate(vertexiterN, vertexstateN)
205-
while isnothing(nextline)
206-
nextout = iterate(outiterN, outstateN)
207-
nextout === nothing && return nothing
208-
b, outstateN = nextout
209-
vertexiterN = c dual(b)
210-
nextline = iterate(vertexiterN)
203+
if n < Nsymbol(a, b, c)
204+
n += 1
205+
# reset the first part of the fusion tree
206+
rest = _fusiontree_iterate(Base.front(uncoupledsectors), a)
207+
else
208+
nextline = iterate(vertexiterN, vertexstateN)
209+
while isnothing(nextline)
210+
nextout = iterate(outiterN, outstateN)
211+
nextout === nothing && return nothing
212+
b, outstateN = nextout
213+
vertexiterN = c dual(b)
214+
nextline = iterate(vertexiterN)
215+
end
216+
a, vertexstateN = nextline
217+
n = 1
218+
rest = _fusiontree_iterate(Base.front(uncoupledsectors), a)
211219
end
212-
a, vertexstateN = nextline
213-
rest = _fusiontree_iterate(Base.front(uncoupledsectors), a)
214220
end
215-
n = 1
216221
restout, restlines, restvertices, reststates = rest
217222
out = (restout..., b)
218223
lines = (restlines..., a)

0 commit comments

Comments
 (0)