@@ -130,10 +130,10 @@ function MTKParameters(
130
130
if has_parameter_dependencies (sys) &&
131
131
(pdeps = get_parameter_dependencies (sys)) != = nothing
132
132
pdeps = Dict (k => fixpoint_sub (v, pdeps) for (k, v) in pdeps)
133
- dep_exprs = ArrayPartition ((wrap . (v) for v in dep_buffer). .. )
133
+ dep_exprs = ArrayPartition ((Any[ 0 for _ in eachindex (v)] for v in dep_buffer). .. )
134
134
for (sym, val) in pdeps
135
135
i, j = ic. dependent_idx[sym]
136
- dep_exprs. x[i][j] = wrap (val)
136
+ dep_exprs. x[i][j] = unwrap (val)
137
137
end
138
138
p = reorder_parameters (ic, full_parameters (sys))
139
139
oop, iip = build_function (dep_exprs, p... )
@@ -398,7 +398,10 @@ function SymbolicIndexingInterface.remake_buffer(sys, oldbuf::MTKParameters, val
398
398
@set! newbuf. nonnumeric = narrow_buffer_type_and_fallback_undefs .(
399
399
oldbuf. nonnumeric, newbuf. nonnumeric)
400
400
if newbuf. dependent_update_oop != = nothing
401
- @set! newbuf. dependent = newbuf. dependent_update_oop (newbuf... )
401
+ @set! newbuf. dependent = narrow_buffer_type_and_fallback_undefs .(
402
+ oldbuf. dependent,
403
+ split_into_buffers (
404
+ newbuf. dependent_update_oop (newbuf... ), oldbuf. dependent, Val (false )))
402
405
end
403
406
return newbuf
404
407
end
@@ -422,6 +425,7 @@ _num_subarrays(v::Tuple) = length(v)
422
425
# getindex indexes the vectors, setindex! linearly indexes values
423
426
# it's inconsistent, but we need it to be this way
424
427
function Base. getindex (buf:: MTKParameters , i)
428
+ i_orig = i
425
429
if ! isempty (buf. tunable)
426
430
i <= _num_subarrays (buf. tunable) && return _subarrays (buf. tunable)[i]
427
431
i -= _num_subarrays (buf. tunable)
@@ -442,7 +446,7 @@ function Base.getindex(buf::MTKParameters, i)
442
446
i <= _num_subarrays (buf. dependent) && return _subarrays (buf. dependent)[i]
443
447
i -= _num_subarrays (buf. dependent)
444
448
end
445
- throw (BoundsError (buf, i ))
449
+ throw (BoundsError (buf, i_orig ))
446
450
end
447
451
function Base. setindex! (p:: MTKParameters , val, i)
448
452
function _helper (buf)
@@ -526,9 +530,6 @@ function jacobian_wrt_vars(pf::F, p::MTKParameters, input_idxs, chunk::C) where
526
530
for (i, val) in zip (input_idxs, p_small_inner)
527
531
_set_parameter_unchecked! (p_big, val, i)
528
532
end
529
- # tunable, repack, _ = SciMLStructures.canonicalize(SciMLStructures.Tunable(), p_big)
530
- # tunable[input_idxs] .= p_small_inner
531
- # p_big = repack(tunable)
532
533
return if pf isa SciMLBase. ParamJacobianWrapper
533
534
buffer = Array {dualtype} (undef, size (pf. u))
534
535
pf (buffer, p_big)
@@ -538,8 +539,6 @@ function jacobian_wrt_vars(pf::F, p::MTKParameters, input_idxs, chunk::C) where
538
539
end
539
540
end
540
541
end
541
- # tunable, _, _ = SciMLStructures.canonicalize(SciMLStructures.Tunable(), p)
542
- # p_small = tunable[input_idxs]
543
542
p_small = parameter_values .((p,), input_idxs)
544
543
cfg = ForwardDiff. JacobianConfig (p_closure, p_small, chunk, tag)
545
544
ForwardDiff. jacobian (p_closure, p_small, cfg, Val (false ))
0 commit comments