Skip to content

Commit 266630d

Browse files
feat: handle additional arguments in wrap_mtkparameters
1 parent cb6ca4c commit 266630d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/systems/abstractsystem.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ end
360360
const MTKPARAMETERS_ARG = Sym{Vector{Vector}}(:___mtkparameters___)
361361

362362
"""
363-
wrap_mtkparameters(sys::AbstractSystem, isscalar::Bool, p_start = 2)
363+
wrap_mtkparameters(sys::AbstractSystem, isscalar::Bool, p_start = 2, offset = Int(is_time_dependent(sys)))
364364
365365
Return function(s) to be passed to the `wrap_code` keyword of `build_function` which
366366
allow the compiled function to be called as `f(u, p, t)` where `p isa MTKParameters`
@@ -370,12 +370,14 @@ the first parameter vector in the out-of-place version of the function. For exam
370370
if a history function (DDEs) was passed before `p`, then the function before wrapping
371371
would have the signature `f(u, h, p..., t)` and hence `p_start` would need to be `3`.
372372
373+
`offset` is the number of arguments at the end of the argument list to ignore. Defaults
374+
to 1 if the system is time-dependent (to ignore `t`) and 0 otherwise.
375+
373376
The returned function is `identity` if the system does not have an `IndexCache`.
374377
"""
375-
function wrap_mtkparameters(sys::AbstractSystem, isscalar::Bool, p_start = 2)
378+
function wrap_mtkparameters(sys::AbstractSystem, isscalar::Bool, p_start = 2,
379+
offset = Int(is_time_dependent(sys)))
376380
if has_index_cache(sys) && get_index_cache(sys) !== nothing
377-
offset = Int(is_time_dependent(sys))
378-
379381
if isscalar
380382
function (expr)
381383
param_args = expr.args[p_start:(end - offset)]

0 commit comments

Comments
 (0)