Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Lookups/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ for f in (:getindex, :view, :dotview)
@propagate_inbounds Base.$f(l::Lookup, i::Union{Int,CartesianIndex}) =
Base.$f(parent(l), i)
# AbstractArray, Colon and CartesianIndices: the lookup is rebuilt around a new parent
@propagate_inbounds Base.$f(l::Lookup, i::Union{AbstractArray,Colon}) =
@propagate_inbounds Base.$f(l::Lookup, i::Union{AbstractVector,Colon}) =
rebuild(l; data=Base.$f(parent(l), i))
@propagate_inbounds function Base.$f(l::Union{Sampled,Categorical}, i::AbstractVector{Int})
if isordered(l)
issorted(i) || throw(ArgumentError("For `ForwardOrdered` or `ReverseOrdered` lookups, indices of `AbstractVector{Int}` must be in ascending order"))
Copy link
Collaborator

@asinghvi17 asinghvi17 Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? Can't we just return Unordered?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it makes other uses type unstable and slow if we do that.

end
rebuild(l; data=Base.$f(parent(l), i))
end
# Selector gets processed with `selectindices`
@propagate_inbounds Base.$f(l::Lookup, i::SelectorOrInterval) = Base.$f(l, selectindices(l, i))
@propagate_inbounds function Base.$f(l::Lookup, i)
Expand Down
Loading