mcabbott / mcabbott/AxisKeys.jl
Make AxisKeys play nicely with AcceleratedArrays
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 154
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Description
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.
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
Start with the lookup logic in src/selectors.jl and compare it with AcceleratedArrays' findall implementation in UniqueSortIndex.jl. Define an abstraction that lets AcceleratedArrays.Interval use efficient lookup while preserving the existing fallback behavior, then verify the interval selection example returns an efficient range.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100