Skip to content

Commit ef55922

Browse files
fix: VoA stack
1 parent 0e877e3 commit ef55922

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/vector_of_array.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ function Base.append!(VA::AbstractVectorOfArray{T, N},
499499
end
500500

501501
function Base.stack(VA::AbstractVectorOfArray; dims = :)
502-
stack(VA.u; dims)
502+
stack(stack.(VA.u); dims)
503503
end
504504

505505
# AbstractArray methods
@@ -633,7 +633,7 @@ function Base.convert(::Type{Array}, VA::AbstractVectorOfArray)
633633
if !allequal(size.(VA.u))
634634
error("Can only convert non-ragged VectorOfArray to Array")
635635
end
636-
return stack(VA.u)
636+
return stack(VA)
637637
end
638638

639639
# statistics

test/interface_tests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ end
109109
@test stack(testva) == [1 4 7; 2 5 8; 3 6 9]
110110
@test stack(testva; dims = 1) == [1 2 3; 4 5 6; 7 8 9]
111111

112+
testva = VectorOfArray([VectorOfArray([ones(2,2), 2ones(2, 2)]), 3ones(2, 2, 2)])
113+
@test stack(testva) == [1.0 1.0; 1.0 1.0;;; 2.0 2.0; 2.0 2.0;;;; 3.0 3.0; 3.0;;; 3.0 3.0; 3.0 3.0]
114+
112115
# convert array from VectorOfArray/DiffEqArray
113116
t = 1:8
114117
recs = [rand(10, 7) for i in 1:8]

0 commit comments

Comments
 (0)