-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
more efficient array indexing with AbstractUnitRange #39896
Conversation
Some tests should be added to check that indexing still works correctly for newly-allowed types of ranges, for example |
Would be good to have this, @Kahanikaar could you add the tests that have been suggested? Not too sure where the tests should go, perhaps to test/abstractarray.jl? You may create a new |
Sure, will look after this, will add the tests to test/abstractarray.jl |
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.
If the test arrays only contain ones, we don’t know that it actually copies the correct numbers. Better use rand
or something like collect(1:10)
.
Tests now use collect in place of ones. |
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.
Thanks for the PR and welcome! Hope this hasn't been too unpleasant an experience, but looks good to me now.
Not at all. It was really great contributing to Julia. Thanks for all the help! @jishnub @sostock @simeonschaub |
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.
It might also be good to test that indexing preserves the type, i.e., typeof(a[x]) === typeof(a)
.
This is not true in general though, although it probably holds for the range types in Eg cases where this doesn't hold (using julia> ones(10)[SOneTo(2)]
2-element SizedArray{Tuple{2},Float64,1,1,Array{Float64,1}} with indices SOneTo(2):
1.0
1.0
julia> ones(10)[Base.IdentityUnitRange(3:5)]
3-element OffsetArray(::Array{Float64,1}, 3:5) with eltype Float64 with indices 3:5:
1.0
1.0
1.0 |
@Kahanikaar is this ready? Waiting for this before merging JuliaArrays/OffsetArrays.jl#211 |
Commits are ready and approved, should I squash them now? @jishnub |
Squashing isn’t necessary, the PR will be squashed when merging it. But it would be nice to resolve the merge conflict. |
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.
The conflict wasn’t resolved correctly, there is an end
missing.
Co-authored-by: Sebastian Stock <[email protected]>
Co-authored-by: Sebastian Stock <[email protected]>
Gentle bump, since this is ready perhaps this may be reviewed? Would be nice to have this merged as there is a demonstrable performance improvement here. |
Co-authored-by: Sebastian Stock <[email protected]>
Co-authored-by: Sebastian Stock <[email protected]>
Co-authored-by: Sebastian Stock <[email protected]>
Co-authored-by: Sebastian Stock <[email protected]>
Fixes #39858
Relaxed method signature for
getindex(A::Array, I:: UnitRange{Int})
which now hasAbstractUnitRange{<:Integer}
as the second argument.