AxisIndices.jl
AxisIndices.jl copied to clipboard
Logical indexing by non-AxisArray fails with confusing error
trafficstars
A = AxisArray(rand(5,3), 1:5, 2:4);
A[(A .< 0.5)]; # works! awesome!
A[(A .< 0.5).data]; # does not work :(
This example is pretty contrived-- the real problem in my real code is the thing that's causing my index to be of type BitArray rather than AxisArray, and that's my fault, but the error didn't help me debug.
ERROR: BoundsError: attempt to access Tuple{AxisIndices.OffsetAxis{Int64, SimpleAxis{Int64, Base.OneTo{Int64}}, Int64}, AxisIndices.OffsetAxis{Int64, SimpleAxis{Int64, Base.OneTo{Int64}}, Int64}} at index [3, 4, 5, 7, 8, 9, 10, 13, 14]
Stacktrace:
[1] to_multi_index
@ ~/.julia/packages/ArrayInterface/CULgf/src/indexing.jl:239 [inlined]
[2] to_indices
@ ~/.julia/packages/ArrayInterface/CULgf/src/indexing.jl:203 [inlined]
[3] to_indices
@ ~/.julia/packages/ArrayInterface/CULgf/src/indexing.jl:195 [inlined]
[4] to_indices
@ ~/.julia/packages/ArrayInterface/CULgf/src/indexing.jl:191 [inlined]
[5] getindex
@ ~/.julia/packages/ArrayInterface/CULgf/src/indexing.jl:392 [inlined]
[6] getindex(A::AxisMatrix{Float64, Matrix{Float64}, AxisIndices.OffsetAxis{Int64, SimpleAxis{Int64, Base.OneTo{Int64}}, Int64}, AxisIndices.OffsetAxis{Int64, SimpleAxis{Int64, Base.OneTo{Int64}}, Int64}}, args::BitMatrix)
@ AxisIndices ~/.julia/packages/AxisIndices/kU4hN/src/arrays.jl:421
[7] top-level scope
@ REPL[8]:1
(checked on master, too)
Any specific suggestions?
Maybe
getindex(A::AxisArray, [I don't understand these arguments], args::BitArray) = error("Logical index of AxisArray must share same axes.")