Skip to content

Commit 52c231f

Browse files
fix: fix overspecialization of nonnumeric buffers in remake_buffer
1 parent 4c680ca commit 52c231f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/systems/parameter_buffer.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,14 @@ function __remake_buffer(indp, oldbuf::MTKParameters, idxs, vals; validate = tru
763763
oldbuf.discrete, newbuf.discrete)
764764
@set! newbuf.constant = narrow_buffer_type_and_fallback_undefs.(
765765
oldbuf.constant, newbuf.constant)
766-
@set! newbuf.nonnumeric = narrow_buffer_type_and_fallback_undefs.(
767-
oldbuf.nonnumeric, newbuf.nonnumeric)
766+
for (oldv, newv) in zip(oldbuf.nonnumeric, newbuf.nonnumeric)
767+
for i in eachindex(oldv)
768+
isassigned(newv, i) && continue
769+
newv[i] = oldv[i]
770+
end
771+
end
772+
@set! newbuf.nonnumeric = Tuple(
773+
typeof(oldv)(newv) for (oldv, newv) in zip(oldbuf.nonnumeric, newbuf.nonnumeric))
768774
if !ArrayInterface.ismutable(oldbuf)
769775
@set! newbuf.tunable = similar_type(oldbuf.tunable, eltype(newbuf.tunable))(newbuf.tunable)
770776
@set! newbuf.initials = similar_type(oldbuf.initials, eltype(newbuf.initials))(newbuf.initials)

0 commit comments

Comments
 (0)