JuliaArrays / JuliaArrays/AxisArrays.jl
Gracefully error when using multidimensional indices
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 207
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
The following error is really hard to debug, particularly given the repeats 2 times which hides what the type of the input is.
Example)
julia> using AxisArrays
julia> aa = AxisArray(rand(10, 5), Axis{:time}(1:10), Axis{:name}([:a, :b, :c, :d, :e]))
10×5 AxisArray{Float64,2,Array{Float64,2},Tuple{Axis{:time,UnitRange{Int64}},Axis{:name,Array{Symbol,1}}}}:
0.204148 0.792777 0.780203 0.222078 0.530742
0.790793 0.684368 0.328124 0.475048 0.407242
0.0292672 0.67966 0.540458 0.429185 0.694913
0.932434 0.748893 0.831468 0.423212 0.496423
0.127433 0.191755 0.404633 0.0733558 0.689208
0.00480001 0.0853037 0.520147 0.29591 0.44223
0.0359702 0.990168 0.636954 0.717789 0.832071
0.0701029 0.94967 0.950602 0.2058 0.56855
0.682146 0.285136 0.287865 0.97511 0.89489
0.370766 0.569141 0.42673 0.917962 0.91706
julia> mask = iseven.(1:10)
10-element BitArray{1}:
false
true
false
true
false
true
false
true
false
true
julia> other = Array{Bool}(trues(5))
5-element Array{Bool,1}:
true
true
true
true
true
julia> aa[mask, other']
ERROR: ArgumentError: index CartesianIndex{2}[CartesianIndex(1, 1), CartesianIndex(1, 2), CartesianIndex(1, 3), CartesianIndex(1, 4), CartesianIndex(1, 5)] not found
Stacktrace:
[1] axisindexes at /Users/rory/.playground/share/simulation/depot/packages/AxisArrays/G6pZY/src/indexing.jl:302 [inlined]
[2] axisindexes at /Users/rory/.playground/share/simulation/depot/packages/AxisArrays/G6pZY/src/indexing.jl:174 [inlined]
[3] macro expansion at /Users/rory/.playground/share/simulation/depot/packages/AxisArrays/G6pZY/src/indexing.jl:354 [inlined]
[4] to_index at /Users/rory/.playground/share/simulation/depot/packages/AxisArrays/G6pZY/src/indexing.jl:311 [inlined]
[5] getindex at /Users/rory/.playground/share/simulation/depot/packages/AxisArrays/G6pZY/src/indexing.jl:117 [inlined] (repeats 2 times)
[6] top-level scope at none:0
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 example in the issue, then inspect src/indexing.jl around the reported axisindexes, to_index, and getindex locations. Trace how the multidimensional indices become the reported CartesianIndex values; done means the same input produces a clear error that identifies the problematic input and indexing situation.
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
- Mostly clear
- Newbie friendliness
- 35/100