Skip to content

Commit

Permalink
[Containers] add function barrier to getindex (#3731)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Apr 15, 2024
1 parent 5ce3e7b commit 0f3f329
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Containers/DenseAxisArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,17 @@ function _kwargs_to_args(A::DenseAxisArray{T,N}; kwargs...) where {T,N}
end
end

function Base.getindex(A::DenseAxisArray{T,N}, args...; kwargs...) where {T,N}
function Base.getindex(A::DenseAxisArray, args...; kwargs...)
if !isempty(kwargs)
if !isempty(args)
error("Cannot index with mix of positional and keyword arguments")
end
return getindex(A, _kwargs_to_args(A; kwargs...)...)
return _getindex_inner(A, _kwargs_to_args(A; kwargs...)...)
end
return _getindex_inner(A, args...)
end

function _getindex_inner(A::DenseAxisArray{T}, args::Vararg{Any,N}) where {T,N}
new_indices = Base.to_index(A, args)
if !any(_is_range, new_indices)
return A.data[new_indices...]::T
Expand Down

0 comments on commit 0f3f329

Please sign in to comment.