Skip to content

Enumerate is incorrect when parallelized #29

@MasonProtter

Description

@MasonProtter

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions