Skip to content

Commit

Permalink
Merge pull request #355 from lxvm/patch-1
Browse files Browse the repository at this point in the history
Update vector_of_array.jl
  • Loading branch information
ChrisRackauckas authored Feb 27, 2024
2 parents e00bdb2 + d06b8a6 commit 8b7627f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/vector_of_array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ Base.@propagate_inbounds function _getindex(A::AbstractVectorOfArray{T, N},
return Adapt.adapt(__parameterless_type(T),
reshape(reduce(hcat, vecs), size(A.u[1])..., length(A.u)))
end
Base.@propagate_inbounds function _getindex(A::AbstractVectorOfArray{T, N},
::NotSymbolic, I::Colon...) where {T <: Number, N}
@assert length(I) == ndims(A.u)
return A.u[I...]
end

Base.@propagate_inbounds function _getindex(A::AbstractVectorOfArray{T, N},
::NotSymbolic, I::AbstractArray{Bool},
Expand Down
3 changes: 3 additions & 0 deletions test/basic_indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,6 @@ foo!(u_vector)
# test efficiency
num_allocs = @allocations foo!(u_matrix)
@test num_allocs == 0

# issue 354
@test VectorOfArray(ones(1))[:] == ones(1)

0 comments on commit 8b7627f

Please sign in to comment.