JuliaArrays / JuliaArrays/StaticArrays.jl
Indexing with extra dimensions errors
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
The indexing behavior is different from static vector and a normal vector when adding extra dimensions
julia> a = @SVector randn(2)
2-element SVector{2, Float64} with indices SOneTo(2):
1.1055415819376984
-1.376116084168465
julia> a[:, 1]
ERROR: BoundsError: attempt to access Tuple{} at index [1]
Stacktrace:
[1] getindex(t::Tuple, i::Int64)
@ Base ./tuple.jl:29
[3] index_sizes
@ ~/.julia/packages/StaticArrays/pwe3X/src/indexing.jl:81 [inlined]
[4] getindex(::SVector{2, Float64}, ::Colon, ::Int64)
@ StaticArrays ~/.julia/packages/StaticArrays/pwe3X/src/indexing.jl:226
julia> b = randn(2)
2-element Vector{Float64}:
0.34780756537216645
-1.63328724070066
julia> b[:, 1]
2-element Vector{Float64}:
0.34780756537216645
-1.63328724070066
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported SVector and ordinary Vector indexing examples, then inspect src/indexing.jl around index_sizes at line 81 and getindex around line 226. Determine why an extra dimension raises BoundsError for SVector; done means the behavior is resolved and matches the ordinary vector case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100