You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia>using ChunkSplitters
julia>collect(chunks(11:10; n=6))
ERROR: ArgumentError: You must either indicate the desired number of chunks (n) or the target size of a chunk (size).
Stacktrace:
[1] missing_input_err()
@ ChunkSplitters ~/.julia/packages/ChunkSplitters/R5lnx/src/ChunkSplitters.jl:118
[2] getchunk(itr::UnitRange{Int64}, ichunk::Int64; n::Int64, size::Int64, split::Symbol)
@ ChunkSplitters ~/.julia/packages/ChunkSplitters/R5lnx/src/ChunkSplitters.jl:274
[3] getchunk
@ ~/.julia/packages/ChunkSplitters/R5lnx/src/ChunkSplitters.jl:273 [inlined]
[4] getchunk
@ ~/.julia/packages/ChunkSplitters/R5lnx/src/ChunkSplitters.jl:293 [inlined]
[5] iterate
@ ~/.julia/packages/ChunkSplitters/R5lnx/src/ChunkSplitters.jl:142 [inlined]
[6] iterate
@ ~/.julia/packages/ChunkSplitters/R5lnx/src/ChunkSplitters.jl:141 [inlined]
[7] copyto!(dest::Vector{StepRange{Int64, Int64}}, src::ChunkSplitters.Chunk{UnitRange{Int64}, ChunkSplitters.FixedCount})
@ Base ./abstractarray.jl:943
[8] _collect
@ ./array.jl:765 [inlined]
[9] collect(itr::ChunkSplitters.Chunk{UnitRange{Int64}, ChunkSplitters.FixedCount})
@ Base ./array.jl:759
[10] top-level scope
@ REPL[32]:1
The error message is clearly wrong and bad.
The fundamental question is what should happen in this case. We could (1) improve the error message or (2) return an empty Vector{StepRange{Int64, Int64}} (consistent with the finite case, e.g. collect(chunks(9:10; n=6))).
To return the empty step range vector one must return nothing from iterate. Additionaly, it seems consistent to return nothing from getchunk. I have implemented this here:
The error message is clearly wrong and bad.
The fundamental question is what should happen in this case. We could (1) improve the error message or (2) return an empty
Vector{StepRange{Int64, Int64}}
(consistent with the finite case, e.g.collect(chunks(9:10; n=6))
).Came up in JuliaFolds2/OhMyThreads.jl#86.
The text was updated successfully, but these errors were encountered: