You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to how lookups are handled in AK, it seems like in many cases the acceleration of AcceleratedArrays isn't used. For example:
using Dates
using AcceleratedArrays
using AxisKeys
dates = accelerate(Date(2018, 1, 1):Day(1):Date(2019, 2, 3), UniqueSortIndex)
sd = Date(2018, 3, 3)
ed = Date(2018, 8, 4)
i = findall(in(AcceleratedArrays.Interval(sd, ed)), dates)
println(i)
@assert isa(i, StepRange) # nice, just 2 searchsorteds happened
A = KeyedArray(rand(length(dates)); date = dates)
# Not happy: AxisKeys is blind to AcceleratedArrays.Interval, crashes
# A(AcceleratedArrays.Interval(sd, ed), :)
# Works, but inefficient - the view created is not a range, but a Vector of Ints, since it just does Interval inclusion in a loop:
# https://github.com/mcabbott/AxisKeys.jl/blob/master/src/selectors.jl#L6
A(AxisKeys.Interval(sd, ed), :)
Could the lookup logic in AK be abstracted a bit, to allow other libraries to implement efficient axis lookup for their types? I think findall function is probably the correct interface, for example: https://github.com/kcajf/AcceleratedArrays.jl/blob/master/src/UniqueSortIndex.jl#L135. The currently implemented lookup logic could be reimplemented in terms of findall too, as a fallback.
The text was updated successfully, but these errors were encountered:
findall(in(IntervalSets.Interval(sd, ed)), dates.parent)
findall(in(IntervalSets.Interval(3,5.5)), 0:10) # same error without Dates
and instead falls back to giving a vector, as you observe. The issue to fix that is JuliaMath/IntervalSets.jl#52 (which should become a PR).
But it remains to figure out what to do with AcceleratedArrays.Interval, without depending on that package. Why does this differ anyway, it's some issue about isless vs <? But it could still subtype AbstractInterval, that would be nice because IntervalSets.jl is a small package for precisely this purpose.
Is there another way to catch this? We could send z::Any to finall(in(z), axiskeys(A,1)) instead of findfirst(isequal(z), axiskeys(A,1)), i.e. treat objects whose type doesn't match eltype of keys as collections, not individual values, but that doesn't seem ideal. For example push!(KeyedArray(rand(3), [:a, :b, :c]), 0.44) has eltype Any.
Due to how lookups are handled in AK, it seems like in many cases the acceleration of AcceleratedArrays isn't used. For example:
Could the lookup logic in AK be abstracted a bit, to allow other libraries to implement efficient axis lookup for their types? I think
findall
function is probably the correct interface, for example: https://github.com/kcajf/AcceleratedArrays.jl/blob/master/src/UniqueSortIndex.jl#L135. The currently implemented lookup logic could be reimplemented in terms offindall
too, as a fallback.The text was updated successfully, but these errors were encountered: