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

Logical indexing by non-AxisArray fails with confusing error #58

Open
grahamas opened this issue Dec 15, 2020 · 2 comments
Open

Logical indexing by non-AxisArray fails with confusing error #58

grahamas opened this issue Dec 15, 2020 · 2 comments

Comments

@grahamas
Copy link

grahamas commented Dec 15, 2020

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)

@Tokazama
Copy link
Owner

Any specific suggestions?

@grahamas
Copy link
Author

grahamas commented Dec 16, 2020

Maybe

getindex(A::AxisArray, [I don't understand these arguments], args::BitArray) = error("Logical index of AxisArray must share same axes.")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants