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
I am getting an error when using chunk if the length of the collection is less than n. I'm not sure if this is intended or a bug.
julia> using ChunkSplitters
julia> chunks(1:0; n=4)[3]
0:-1
julia> chunks(1:2; n=4)[3]
ERROR: ArgumentError: ichunk must be less or equal to the length of the ChunksIterator
Stacktrace:
[1] getchunkindices(c::ChunkSplitters.Internals.ViewChunks{…}, ichunk::Int64)
@ ChunkSplitters.Internals ~/.julia/packages/ChunkSplitters/p2yrz/src/internals.jl:158
[2] getindex(c::ChunkSplitters.Internals.ViewChunks{…}, i::Int64)
@ ChunkSplitters.Internals ~/.julia/packages/ChunkSplitters/p2yrz/src/internals.jl:102
[3] top-level scope
@ REPL[21]:1
Some type information was truncated. Use `show(err)` to see complete types.
I would expect chunks(1:2; n=4)[3] to also be an empty range to be consistent with chunks(1:0; n=4)[3].
The text was updated successfully, but these errors were encountered:
The error is expected, what I think is not expected is not throwing an error for chunks(1:0; n=4)[3], since the iterator is empty. I'll check if we did that on purpose for some reason.
lmiq
linked a pull request
Mar 20, 2025
that will
close
this issue
In the PR linked above the behavior becomes consistent in the sense that it will throw a bounds error for empty iterators, when direct indexing is intended. This won´t affect the collect for empty iterators, returning an empty collection of chunks, which was an intentional feature.
I am getting an error when using
chunk
if the length of the collection is less thann
. I'm not sure if this is intended or a bug.I would expect
chunks(1:2; n=4)[3]
to also be an empty range to be consistent withchunks(1:0; n=4)[3]
.The text was updated successfully, but these errors were encountered: