Transducers.jl icon indicating copy to clipboard operation
Transducers.jl copied to clipboard

`Enumerate` is incorrect when parallelized

Open MasonProtter opened this issue 1 year ago • 0 comments

MWE:

julia> using Transducers

julia> 1:6 |> Enumerate() |> x -> tcollect(x; basesize=1)
6-element Vector{Tuple{Int64, Int64}}:
 (1, 1)
 (1, 2)
 (1, 3)
 (1, 4)
 (1, 5)
 (1, 6)

julia> 1:6 |> Enumerate() |> x -> tcollect(x; basesize=2)
6-element Vector{Tuple{Int64, Int64}}:
 (1, 1)
 (2, 2)
 (1, 3)
 (2, 4)
 (1, 5)
 (2, 6)

julia> 1:6 |> Enumerate() |> x -> tcollect(x; basesize=3)
6-element Vector{Tuple{Int64, Int64}}:
 (1, 1)
 (2, 2)
 (3, 3)
 (1, 4)
 (2, 5)
 (3, 6)

This is because each time you split 1:6 in half, you hand that thing a new Enumerate and it starts counting from zero again.

I think the only way to fix this is to add a new interface that also "halves" a reducer.

Alternatively we should just delete this

MasonProtter avatar Feb 05 '24 19:02 MasonProtter