Skip to content

Commit

Permalink
check AbstractVector{Int} index sorted order
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Nov 3, 2024
1 parent 6e96e27 commit 93ad378
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Lookups/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ for f in (:getindex, :view, :dotview)
@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})
rebuild(l; data=Base.$f(parent(l), i), order=Unordered())
if isordered(l)
issorted(i) || throw(ArgumentError("For `ForwardOrdered` or `ReverseOrdered` lookups, indices of `AbstractVector{Int}` must be in ascending order"))
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))
Expand Down

0 comments on commit 93ad378

Please sign in to comment.