-
Notifications
You must be signed in to change notification settings - Fork 8
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
out of bounds error on empty iterator indexing #59
base: main
Are you sure you want to change the base?
Conversation
@@ -103,8 +102,8 @@ Base.getindex(c::ViewChunks{T,C,S}, i::Int) where {T,C,S} = @view(c.collection[g | |||
|
|||
Base.eltype(::IndexChunks{T,C,Consecutive}) where {T,C} = UnitRange{Int} | |||
Base.eltype(::IndexChunks{T,C,RoundRobin}) where {T,C} = StepRange{Int,Int} | |||
Base.eltype(c::ViewChunks{T,C,Consecutive}) where {T,C} = typeof(c[firstindex(c)]) | |||
Base.eltype(c::ViewChunks{T,C,RoundRobin}) where {T,C} = typeof(c[firstindex(c)]) | |||
Base.eltype(c::ViewChunks{T,C,Consecutive}) where {T,C} = typeof(@view(c.collection[firstindex(c.collection):lastindex(c.collection)])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are important to allow eltype
to return the proper types without having to call getchunkindices
. firstindex
and lastindex
are considered part of the required interface.
Want to take a look? I think this is more consistent throwing an error for empty iterators and can be considered a bug-fix. OhMyThreads.jl tests are not affected. |
Haven't look at this in detail, but why are you throwing an |
The "historical" reason is that this error was reached when the Now, we can turn that into a |
Yes, this fixes #58 |
This PR aims to fix #58 by considering out-of-bounds indexing of the chunk iterator an error even if the iterator is empty.
Obs: Checked that all OhMyThreads tests passed.
Previously:
Now: