SparseArrays.jl
SparseArrays.jl copied to clipboard
Sparse array index lowering
When implementing custom array types it's useful to independently resolve indices using to_indices, and subsequently index into an underlying array with them. Right now this works with Array, but fails when the array is sparse:
using SparseArrays
let x = sparse([1 2; 3 4])
x[1, [true, false]] # Works
I′ = to_indices(x, (1, [true, false]))
x[I′...] # => getindex not defined for Base.LogicalIndex{Int64,Array{Bool,1}}
end
This also comes up when indexing into e.g a custom array with user-defined index types, or with Not from InvertedIndices.jl (this originally came up in an issue there.)
I think it has to do with the way that sparse arrays hook into the to_indices machinery.