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

Offset arrays indexing of indexes bug #27986

Closed
andyferris opened this issue Jul 7, 2018 · 0 comments
Closed

Offset arrays indexing of indexes bug #27986

andyferris opened this issue Jul 7, 2018 · 0 comments
Labels
arrays [a, r, r, a, y, s] bug Indicates an unexpected problem or unintended behavior

Comments

@andyferris
Copy link
Member

I found some questionable behavior regarding indices of OffsetArrays.

julia> include("test/TestHelpers.jl")
Main.TestHelpers

julia> using Main.TestHelpers.OAs

julia> a = [11,12,13]
3-element Array{Int64,1}:
 11
 12
 13

julia> b = OffsetArray(a, (-3,))
OffsetArray{Int64,1,Array{Int64,1}} with indices -2:0:
 11
 12
 13

julia> i = LinearIndices(b)
LinearIndices{1,Tuple{Base.Slice{UnitRange{Int64}}}} with indices -2:0:
 -2
 -1
  0

julia> i[-2]
-2

julia> i[-2:end]
-5:-3

I suspect this is a bug. Because these are a Slice I feel the scalar getindex behavior is correct and the behavior here is wrongly assuming 1-based indexing.

@andyferris andyferris added bug Indicates an unexpected problem or unintended behavior arrays [a, r, r, a, y, s] labels Jul 7, 2018
timholy added a commit that referenced this issue Jul 10, 2018
Fix offset LinearIndices range indexing (fixes #27986)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s] bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant