@@ -318,6 +318,43 @@ function _set_parameter_unchecked!(
318
318
p. dependent_update_iip (ArrayPartition (p. dependent), p... )
319
319
end
320
320
321
+ function SymbolicIndexingInterface. remake_buffer (sys, oldbuf:: MTKParameters , vals:: Dict )
322
+ buftypes = Dict {Tuple{Any, Int}, Any} ()
323
+ for (p, val) in vals
324
+ (idx = parameter_index (sys, p)) isa ParameterIndex || continue
325
+ k = (idx. portion, idx. idx[1 ])
326
+ buftypes[k] = Union{get (buftypes, k, Union{}), typeof (val)}
327
+ end
328
+
329
+ newbufs = []
330
+ for (portion, old) in [(SciMLStructures. Tunable (), oldbuf. tunable)
331
+ (SciMLStructures. Discrete (), oldbuf. discrete)
332
+ (SciMLStructures. Constants (), oldbuf. constant)
333
+ (DEPENDENT_PORTION, oldbuf. dependent)
334
+ (NONNUMERIC_PORTION, oldbuf. nonnumeric)]
335
+ if isempty (old)
336
+ push! (newbufs, old)
337
+ continue
338
+ end
339
+ new = Any[copy (i) for i in old]
340
+ for i in eachindex (new)
341
+ buftype = get (buftypes, (portion, i), eltype (new[i]))
342
+ new[i] = similar (new[i], buftype)
343
+ end
344
+ push! (newbufs, Tuple (new))
345
+ end
346
+ newbuf = MTKParameters (
347
+ newbufs... , oldbuf. dependent_update_iip, oldbuf. dependent_update_oop)
348
+ for (p, val) in vals
349
+ _set_parameter_unchecked! (
350
+ newbuf, val, parameter_index (sys, p); update_dependent = false )
351
+ end
352
+ if newbuf. dependent_update_iip != = nothing
353
+ newbuf. dependent_update_iip (ArrayPartition (newbuf. dependent), newbuf... )
354
+ end
355
+ return newbuf
356
+ end
357
+
321
358
_subarrays (v:: AbstractVector ) = isempty (v) ? () : (v,)
322
359
_subarrays (v:: ArrayPartition ) = v. x
323
360
_subarrays (v:: Tuple ) = v
0 commit comments