Skip to content

Commit

Permalink
fix: make remake_buffer work for array symbolics
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed May 22, 2024
1 parent 71408bb commit 62a010f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/remake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,24 @@ function remake_buffer(sys, oldbuffer::AbstractArray, vals::Dict)
if ArrayInterface.ismutable(oldbuffer) && !isa(oldbuffer, MArray)
elT = Union{}
for val in values(vals)
elT = promote_type(elT, typeof(val))
if val isa AbstractArray
valT = eltype(val)
else
valT = typeof(val)
end
elT = promote_type(elT, valT)
end

newbuffer = similar(oldbuffer, elT)
copyto!(newbuffer, oldbuffer)
setu(sys, collect(keys(vals)))(newbuffer, elT.(values(vals)))
for (k, v) in vals
if v isa AbstractArray
v = elT.(v)
else
v = elT(v)
end
setu(sys, k)(newbuffer, v)
end
else
mutbuffer = remake_buffer(sys, collect(oldbuffer), vals)
newbuffer = similar_type(oldbuffer, eltype(mutbuffer))(mutbuffer)
Expand Down

0 comments on commit 62a010f

Please sign in to comment.