Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions src/vector_of_arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -573,3 +573,5 @@ function consgroupedview(source::AbstractVector, target::NamedTuple{syms,<:NTupl
elem_ptr = consgrouped_ptrs(source)
map(X -> VectorOfVectors(X, elem_ptr), target)
end

Base.reduce(::typeof(vcat), V::VectorOfVectors) = flatview(V)
15 changes: 15 additions & 0 deletions test/vector_of_arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ using ArraysOfArrays: full_consistency_checks, append_elemptr!, element_ptr
B1_copy = @inferred(copy(B1)); B3_copy = @inferred(copy(B3))
append!(B1_copy, B3_copy)
@test B1_copy.data == vcat(B1.data, B3.data)

V1 = VectorOfVectors(ref_AoA1(Float32, 1))
V2 = VectorOfVectors(ref_AoA1(Float32, 2))
V3 = VectorOfVectors(ref_AoA1(Float32, 3))
V4 = VectorOfVectors(ref_AoA1(Float32, 4))

@test reduce(vcat, V1) == flatview(V1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's test the behavior

@test reduce(vcat, V1) == reduce(vcat, Array(V1))

instead.

@test reduce(vcat, V2) == flatview(V2)
@test reduce(vcat, V3) == flatview(V3)
@test reduce(vcat, V4) == flatview(V4)

@test (@allocated reduce(vcat, V1)) == 0
@test (@allocated reduce(vcat, V2)) == 0
@test (@allocated reduce(vcat, V3)) == 0
@test (@allocated reduce(vcat, V4)) == 0
end


Expand Down