Skip to content

Update vector_of_array.jl #355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
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
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)