File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -95,12 +95,12 @@ function recursivecopy!(
9595end
9696
9797function recursivecopy! (b:: AbstractVectorOfArray , a:: AbstractVectorOfArray )
98- if ArrayInterface . ismutable ( eltype ( b. u) )
99- @inbounds for i in eachindex (b. u, a . u)
98+ @inbounds for i in eachindex ( b. u, a . u )
99+ if ArrayInterface . ismutable (b. u[i]) || b . u[i] isa AbstractVectorOfArray
100100 recursivecopy! (b. u[i], a. u[i])
101+ else
102+ b. u[i] = recursivecopy (a. u[i])
101103 end
102- else
103- copyto! (b. u, a. u)
104104 end
105105 return b
106106end
Original file line number Diff line number Diff line change 139139 @test u1. u[2 ] == [2.0 , 2.0 ]
140140 @test u1. u[1 ] isa SVector
141141 @test u1. u[2 ] isa SVector
142+
143+ # mixed/nested partition types create a Union eltype for `u`.
144+ # recursivecopy! must not fall back to a shallow copy in this case.
145+ a = VectorOfArray ([ones (2 ), VectorOfArray ([1.0 , 1.0 ])])
146+ b = recursivecopy (a)
147+ recursivecopy! (b, a)
148+ @test ! (b. u[1 ] === a. u[1 ])
149+ @test ! (b. u[2 ] === a. u[2 ])
150+ b. u[1 ][1 ] = 99.0
151+ @test a. u[1 ][1 ] == 1.0
142152end
143153
144154@testset " VectorOfArray similar with nested scalar leaves" begin
You can’t perform that action at this time.
0 commit comments