@@ -140,7 +140,7 @@ function MTKParameters(
140
140
dep_exprs = ArrayPartition ((Any[missing for _ in 1 : length (v)] for v in dep_buffer). .. )
141
141
for (sym, val) in pdeps
142
142
i, j = ic. dependent_idx[sym]
143
- dep_exprs. x[i][j] = wrap (val)
143
+ dep_exprs. x[i][j] = unwrap (val)
144
144
end
145
145
dep_exprs = identity .(dep_exprs)
146
146
p = reorder_parameters (ic, full_parameters (sys))
@@ -423,7 +423,10 @@ function SymbolicIndexingInterface.remake_buffer(sys, oldbuf::MTKParameters, val
423
423
@set! newbuf. nonnumeric = narrow_buffer_type_and_fallback_undefs .(
424
424
oldbuf. nonnumeric, newbuf. nonnumeric)
425
425
if newbuf. dependent_update_oop != = nothing
426
- @set! newbuf. dependent = newbuf. dependent_update_oop (newbuf... )
426
+ @set! newbuf. dependent = narrow_buffer_type_and_fallback_undefs .(
427
+ oldbuf. dependent,
428
+ split_into_buffers (
429
+ newbuf. dependent_update_oop (newbuf... ), oldbuf. dependent, Val (false )))
427
430
end
428
431
return newbuf
429
432
end
@@ -447,6 +450,7 @@ _num_subarrays(v::Tuple) = length(v)
447
450
# getindex indexes the vectors, setindex! linearly indexes values
448
451
# it's inconsistent, but we need it to be this way
449
452
function Base. getindex (buf:: MTKParameters , i)
453
+ i_orig = i
450
454
if ! isempty (buf. tunable)
451
455
i <= _num_subarrays (buf. tunable) && return _subarrays (buf. tunable)[i]
452
456
i -= _num_subarrays (buf. tunable)
@@ -467,7 +471,7 @@ function Base.getindex(buf::MTKParameters, i)
467
471
i <= _num_subarrays (buf. dependent) && return _subarrays (buf. dependent)[i]
468
472
i -= _num_subarrays (buf. dependent)
469
473
end
470
- throw (BoundsError (buf, i ))
474
+ throw (BoundsError (buf, i_orig ))
471
475
end
472
476
function Base. setindex! (p:: MTKParameters , val, i)
473
477
function _helper (buf)
@@ -551,9 +555,6 @@ function jacobian_wrt_vars(pf::F, p::MTKParameters, input_idxs, chunk::C) where
551
555
for (i, val) in zip (input_idxs, p_small_inner)
552
556
_set_parameter_unchecked! (p_big, val, i)
553
557
end
554
- # tunable, repack, _ = SciMLStructures.canonicalize(SciMLStructures.Tunable(), p_big)
555
- # tunable[input_idxs] .= p_small_inner
556
- # p_big = repack(tunable)
557
558
return if pf isa SciMLBase. ParamJacobianWrapper
558
559
buffer = Array {dualtype} (undef, size (pf. u))
559
560
pf (buffer, p_big)
@@ -563,8 +564,6 @@ function jacobian_wrt_vars(pf::F, p::MTKParameters, input_idxs, chunk::C) where
563
564
end
564
565
end
565
566
end
566
- # tunable, _, _ = SciMLStructures.canonicalize(SciMLStructures.Tunable(), p)
567
- # p_small = tunable[input_idxs]
568
567
p_small = parameter_values .((p,), input_idxs)
569
568
cfg = ForwardDiff. JacobianConfig (p_closure, p_small, chunk, tag)
570
569
ForwardDiff. jacobian (p_closure, p_small, cfg, Val (false ))
0 commit comments