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

Support for enumerate(chunks(...)) #117

Merged
merged 3 commits into from
Sep 18, 2024
Merged

Support for enumerate(chunks(...)) #117

merged 3 commits into from
Sep 18, 2024

Conversation

carstenbauer
Copy link
Member

With this PR:

julia> @tasks for (c,v) in enumerate(chunks(rand(10); n=2))
           @set chunking=false
           @show c
       end
c = 2
c = 1

julia> @tasks for (c,v) in enumerate(chunks(rand(10); n=2))
           @set chunking=false
           @set reducer=+
           c
       end
3

julia> @tasks for (c,v) in enumerate(chunks(rand(10); n=2))
           @set chunking=false
           @set collect=true
           c
       end
2-element Vector{Int64}:
 1
 2

Before this PR:

julia> @tasks for (c,v) in enumerate(chunks(rand(10); n=2))
           @set chunking=false
           @show c
       end
ERROR: MethodError: no method matching keys(::ChunkSplitters.Enumerate{ChunkSplitters.Chunk{…}})

Closest candidates are:
  keys(::Pkg.Registry.RegistryInstance)
   @ Pkg ~/.julia/juliaup/julia-1.10.5+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/Registry/registry_instance.jl:447
  keys(::LibGit2.GitTree)
   @ Revise ~/.julia/packages/Revise/uvGMC/src/git.jl:52
  keys(::Core.SimpleVector)
   @ Base essentials.jl:781
  ...

Stacktrace:
 [1] eachindex(itrs::ChunkSplitters.Enumerate{ChunkSplitters.Chunk{…}})
   @ Base ./abstractarray.jl:318
 [2] _tmapreduce(f::Function, op::Function, Arrs::Tuple{…}, ::Type{…}, scheduler::DynamicScheduler{…}, mapreduce_kwargs::@NamedTuple{})
   @ OhMyThreads.Implementation ~/repos/OhMyThreads.jl/src/implementation.jl:97
 [3] #tmapreduce#21
   @ ~/repos/OhMyThreads.jl/src/implementation.jl:67 [inlined]
 [4] tmapreduce
   @ ~/repos/OhMyThreads.jl/src/implementation.jl:55 [inlined]
 [5] tforeach(f::Function, A::ChunkSplitters.Enumerate{ChunkSplitters.Chunk{…}}; kwargs::@Kwargs{chunking::Bool})
   @ OhMyThreads.Implementation ~/repos/OhMyThreads.jl/src/implementation.jl:293
 [6] macro expansion
   @ ~/repos/OhMyThreads.jl/src/macro_impl.jl:107 [inlined]
 [7] top-level scope
   @ REPL[4]:1
Some type information was truncated. Use `show(err)` to see complete types.

@carstenbauer carstenbauer added enhancement New feature or request needs changelog labels Sep 18, 2024
@carstenbauer
Copy link
Member Author

@MasonProtter please merge if adequate.

Copy link
Member

@MasonProtter MasonProtter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MasonProtter MasonProtter merged commit 8b657fc into master Sep 18, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants