Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enumerate is incorrect when parallelized #29

Open
MasonProtter opened this issue Feb 5, 2024 · 0 comments
Open

Enumerate is incorrect when parallelized #29

MasonProtter opened this issue Feb 5, 2024 · 0 comments

Comments

@MasonProtter
Copy link
Member

MasonProtter commented Feb 5, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant