diff --git a/src/remake.jl b/src/remake.jl index 2dbfe08..0eb06c3 100644 --- a/src/remake.jl +++ b/src/remake.jl @@ -11,7 +11,7 @@ returned buffer should be of the same type (ignoring type-parameters) as `oldbuf This method is already implemented for `remake_buffer(sys, oldbuffer::AbstractArray, vals::Dict)` and supports static arrays -as well. +as well. It is also implemented for `oldbuffer::Tuple`. """ function remake_buffer(sys, oldbuffer::AbstractArray, vals::Dict) # similar when used with an `MArray` and nonconcrete eltype returns a @@ -23,6 +23,7 @@ function remake_buffer(sys, oldbuffer::AbstractArray, vals::Dict) end newbuffer = similar(oldbuffer, elT) + copyto!(newbuffer, oldbuffer) setu(sys, collect(keys(vals)))(newbuffer, elT.(values(vals))) else mutbuffer = remake_buffer(sys, collect(oldbuffer), vals) diff --git a/test/remake_test.jl b/test/remake_test.jl index 9f4bad1..0618e2e 100644 --- a/test/remake_test.jl +++ b/test/remake_test.jl @@ -7,17 +7,17 @@ for (buf, newbuf, newvals) in [ # standard operation ([1.0, 2.0, 3.0], [2.0, 3.0, 4.0], Dict(:x => 2.0, :y => 3.0, :z => 4.0)), # buffer type "demotion" - ([1.0, 2.0, 3.0], [2, 3, 4], Dict(:x => 2, :y => 3, :z => 4)), + ([1.0, 2.0, 3.0], [2, 2, 3], Dict(:x => 2)), # buffer type promotion - ([1, 2, 3], [2.0, 3.0, 4.0], Dict(:x => 2.0, :y => 3.0, :z => 4.0)), + ([1, 2, 3], [2.0, 2.0, 3.0], Dict(:x => 2.0)), # value type promotion ([1, 2, 3], [2.0, 3.0, 4.0], Dict(:x => 2, :y => 3.0, :z => 4.0)), # standard operation ([1.0, 2.0, 3.0], [2.0, 3.0, 4.0], Dict(:a => 2.0, :b => 3.0, :c => 4.0)), # buffer type "demotion" - ([1.0, 2.0, 3.0], [2, 3, 4], Dict(:a => 2, :b => 3, :c => 4)), + ([1.0, 2.0, 3.0], [2, 2, 3], Dict(:a => 2)), # buffer type promotion - ([1, 2, 3], [2.0, 3.0, 4.0], Dict(:a => 2.0, :b => 3.0, :c => 4.0)), + ([1, 2, 3], [2.0, 2.0, 3.0], Dict(:a => 2.0)), # value type promotion ([1, 2, 3], [2, 3.0, 4.0], Dict(:a => 2, :b => 3.0, :c => 4.0)) ]