Skip to content

Commit 03df63a

Browse files
fix multiscale iteration
1 parent 224b266 commit 03df63a

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/level_iterations.jl

+19-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,26 @@ struct LevelIterIdx{T}
55
end
66
LevelIterIdx(S::AbstractMultiScaleArray, n::Int) = LevelIterIdx(level_iter(S, n))
77

8-
Base.start(l::LevelIterIdx) = (start(l.iter), 1)
9-
function Base.next(l::LevelIterIdx, state)
8+
start(l::LevelIterIdx) = (start(l.iter), 1)
9+
function next(l::LevelIterIdx, state)
1010
val, new_state = next(l.iter, state[1])
1111
end_idx = state[2] + length(val) - 1
1212
((val, state[2], end_idx), (new_state, end_idx + 1))
1313
end
14-
Base.done(l::LevelIterIdx, state) = done(l.iter, state[1])
14+
done(l::LevelIterIdx, state) = done(l.iter, state[1])
15+
16+
function Base.iterate(l::LevelIterIdx)
17+
x = iterate(l.iter)
18+
x == nothing && return nothing
19+
val, new_state = x
20+
end_idx = 1 + length(val) - 1
21+
((val, 1, end_idx), (new_state, end_idx + 1))
22+
end
23+
24+
function Base.iterate(l::LevelIterIdx,state)
25+
x = iterate(l.iter,state[1])
26+
x == nothing && return nothing
27+
val, new_state = x
28+
end_idx = state[2] + length(val) - 1
29+
((val, state[2], end_idx), (new_state, end_idx + 1))
30+
end

0 commit comments

Comments
 (0)