Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Jul 15, 2024
1 parent 37bf8ef commit 40846f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/Lookups/selector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,16 @@ struct _True end
struct _False end

@inline selectindices(l::Lookup, sel::At; kw...) = at(l, sel; kw...)
@inline selectindices(l::Lookup, sel::At{<:AbstractVector}; kw...) = _selectvec(l, sel; kw...)
@inline selectindices(l::Lookup, sel::At{<:Tuple{<:Any,<:Any}}; kw...) = _selecttuple(l, sel; kw...)
@inline selectindices(l::Lookup, sel::At{<:AbstractVector}; kw...) =
_selectvec(l, sel; kw...)
@inline selectindices(l::Lookup, sel::At{<:Tuple{<:Any,<:Any}}; kw...) =
_selecttuple(l, sel; kw...)
# Handle lookups of Tuple
@inline selectindices(l::Lookup{<:Tuple}, sel::At{<:Tuple}; kw...) = at(l, sel; kw...)
@inline selectindices(l::Lookup{<:Tuple}, sel::At{<:Tuple{<:Tuple,<:Tuple}}; kw...) = _selecttuple(l, sel; kw...)
@inline selectindices(l::Lookup{<:Tuple}, sel::At{<:Tuple{<:Any,<:Any}}; kw...) =
at(l, sel; kw...)
@inline selectindices(l::Lookup{<:Tuple}, sel::At{<:Tuple{<:Tuple,<:Tuple}}; kw...) =
_selecttuple(l, sel; kw...)

@inline _selectvec(l, sel; kw...) = [selectindices(l, rebuild(sel, v); kw...) for v in val(sel)]
@inline function _selecttuple(l, sel; kw...)
Expand Down
2 changes: 1 addition & 1 deletion test/dimindices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ end
@test @inferred broadcast(ds -> C[ds...] + 2, dsa2) == fill(2.0, 4, 3)
@test @inferred broadcast(ds -> C[ds...], dsa2[X(At(7.0))]) == [0.0 for i in 1:3]
# without atol it errors
@test_throws ArgumentError broadcast(ds -> C[ds...] + 2, ds) == fill(2.0, 4, 3)
@test_throws SelectorError broadcast(ds -> C[ds...] + 2, ds) == fill(2.0, 4, 3)
# no dims errors
@test_throws ArgumentError DimSelectors(zeros(2, 2))
@test_throws ArgumentError DimSelectors(nothing)
Expand Down

0 comments on commit 40846f1

Please sign in to comment.