Skip to content

Commit 50d95ba

Browse files
committed
Fix again
1 parent fd1a84e commit 50d95ba

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/vector_of_array.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -905,8 +905,10 @@ for (type, N_expr) in [
905905
else
906906
unpacked = unpack_voa(bc, i)
907907
arr_type = StaticArraysCore.similar_type(dest[:, i])
908-
dest[:, i] = if length(unpacked) == 1
908+
dest[:, i] = if length(unpacked) == 1 && length(dest[:, i]) == 1
909909
arr_type(unpacked[1])
910+
elseif length(unpacked) == 1
911+
fill(copy(unpacked), arr_type)
910912
else
911913
arr_type(unpacked[j] for j in eachindex(unpacked))
912914
end

test/copy_static_array_test.jl

+13-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ b = recursivecopy(a)
8383
a[1] *= 2
8484
@test a[1] != b[1]
8585

86-
# Broadcasting when SVector{1}
86+
# Broadcasting when SVector{N} where N = 1
8787
a = [SVector(0.0) for _ in 1:2]
8888
a_voa = VectorOfArray(a)
8989
b_voa = copy(a_voa)
@@ -93,6 +93,12 @@ a_voa[2] = SVector(1.0)
9393
@test b_voa[1] == a_voa[1]
9494
@test b_voa[2] == a_voa[2]
9595

96+
a = [SVector(0.0) for _ in 1:2]
97+
a_voa = VectorOfArray(a)
98+
a_voa .= 1.0
99+
@test a_voa[1] == SVector(1.0)
100+
@test a_voa[2] == SVector(1.0)
101+
96102
# Broadcasting when SVector{N} where N > 1
97103
a = [SVector(0.0, 0.0) for _ in 1:2]
98104
a_voa = VectorOfArray(a)
@@ -102,3 +108,9 @@ a_voa[2] = SVector(1.0, 1.0)
102108
@. b_voa = a_voa
103109
@test b_voa[1] == a_voa[1]
104110
@test b_voa[2] == a_voa[2]
111+
112+
a = [SVector(0.0, 0.0) for _ in 1:2]
113+
a_voa = VectorOfArray(a)
114+
a_voa .= 1.0
115+
@test a_voa[1] == SVector(1.0, 1.0)
116+
@test a_voa[2] == SVector(1.0, 1.0)

0 commit comments

Comments
 (0)