@@ -397,7 +397,8 @@ function SymbolicIndexingInterface.remake_buffer(sys, oldbuf::MTKParameters, val
397
397
@set! newbuf. nonnumeric = narrow_buffer_type_and_fallback_undefs .(
398
398
oldbuf. nonnumeric, newbuf. nonnumeric)
399
399
if newbuf. dependent_update_oop != = nothing
400
- @set! newbuf. dependent = newbuf. dependent_update_oop (newbuf... )
400
+ @set! newbuf. dependent = split_into_buffers (
401
+ newbuf. dependent_update_oop (newbuf... ), oldbuf. dependent)
401
402
end
402
403
return newbuf
403
404
end
@@ -421,6 +422,7 @@ _num_subarrays(v::Tuple) = length(v)
421
422
# getindex indexes the vectors, setindex! linearly indexes values
422
423
# it's inconsistent, but we need it to be this way
423
424
function Base. getindex (buf:: MTKParameters , i)
425
+ i_orig = i
424
426
if ! isempty (buf. tunable)
425
427
i <= _num_subarrays (buf. tunable) && return _subarrays (buf. tunable)[i]
426
428
i -= _num_subarrays (buf. tunable)
@@ -441,7 +443,7 @@ function Base.getindex(buf::MTKParameters, i)
441
443
i <= _num_subarrays (buf. dependent) && return _subarrays (buf. dependent)[i]
442
444
i -= _num_subarrays (buf. dependent)
443
445
end
444
- throw (BoundsError (buf, i ))
446
+ throw (BoundsError (buf, i_orig ))
445
447
end
446
448
function Base. setindex! (p:: MTKParameters , val, i)
447
449
function _helper (buf)
@@ -525,9 +527,6 @@ function jacobian_wrt_vars(pf::F, p::MTKParameters, input_idxs, chunk::C) where
525
527
for (i, val) in zip (input_idxs, p_small_inner)
526
528
_set_parameter_unchecked! (p_big, val, i)
527
529
end
528
- # tunable, repack, _ = SciMLStructures.canonicalize(SciMLStructures.Tunable(), p_big)
529
- # tunable[input_idxs] .= p_small_inner
530
- # p_big = repack(tunable)
531
530
return if pf isa SciMLBase. ParamJacobianWrapper
532
531
buffer = Array {dualtype} (undef, size (pf. u))
533
532
pf (buffer, p_big)
@@ -537,8 +536,6 @@ function jacobian_wrt_vars(pf::F, p::MTKParameters, input_idxs, chunk::C) where
537
536
end
538
537
end
539
538
end
540
- # tunable, _, _ = SciMLStructures.canonicalize(SciMLStructures.Tunable(), p)
541
- # p_small = tunable[input_idxs]
542
539
p_small = parameter_values .((p,), input_idxs)
543
540
cfg = ForwardDiff. JacobianConfig (p_closure, p_small, chunk, tag)
544
541
ForwardDiff. jacobian (p_closure, p_small, cfg, Val (false ))
0 commit comments