Skip to content

Commit f8030f8

Browse files
refactor: allow changing name of parameter argument in delay_to_function
1 parent 50148d4 commit f8030f8

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,29 +242,32 @@ function isdelay(var, iv)
242242
return false
243243
end
244244
const DDE_HISTORY_FUN = Sym{Symbolics.FnType{Tuple{Any, <:Real}, Vector{Real}}}(:___history___)
245-
function delay_to_function(sys::AbstractODESystem, eqs = full_equations(sys))
245+
const DEFAULT_PARAMS_ARG = Sym{Any}(:ˍ₋arg3)
246+
function delay_to_function(
247+
sys::AbstractODESystem, eqs = full_equations(sys); history_arg = DEFAULT_PARAMS_ARG)
246248
delay_to_function(eqs,
247249
get_iv(sys),
248250
Dict{Any, Int}(operation(s) => i for (i, s) in enumerate(unknowns(sys))),
249251
parameters(sys),
250-
DDE_HISTORY_FUN)
252+
DDE_HISTORY_FUN; history_arg)
251253
end
252-
function delay_to_function(eqs::Vector, iv, sts, ps, h)
253-
delay_to_function.(eqs, (iv,), (sts,), (ps,), (h,))
254+
function delay_to_function(eqs::Vector, iv, sts, ps, h; history_arg = DEFAULT_PARAMS_ARG)
255+
delay_to_function.(eqs, (iv,), (sts,), (ps,), (h,); history_arg)
254256
end
255-
function delay_to_function(eq::Equation, iv, sts, ps, h)
256-
delay_to_function(eq.lhs, iv, sts, ps, h) ~ delay_to_function(eq.rhs, iv, sts, ps, h)
257+
function delay_to_function(eq::Equation, iv, sts, ps, h; history_arg = DEFAULT_PARAMS_ARG)
258+
delay_to_function(eq.lhs, iv, sts, ps, h; history_arg) ~ delay_to_function(
259+
eq.rhs, iv, sts, ps, h; history_arg)
257260
end
258-
function delay_to_function(expr, iv, sts, ps, h)
261+
function delay_to_function(expr, iv, sts, ps, h; history_arg = DEFAULT_PARAMS_ARG)
259262
if isdelay(expr, iv)
260263
v = operation(expr)
261264
time = arguments(expr)[1]
262265
idx = sts[v]
263-
return term(getindex, h(Sym{Any}(:ˍ₋arg3), time), idx, type = Real) # BIG BIG HACK
266+
return term(getindex, h(history_arg, time), idx, type = Real) # BIG BIG HACK
264267
elseif iscall(expr)
265268
return maketerm(typeof(expr),
266269
operation(expr),
267-
map(x -> delay_to_function(x, iv, sts, ps, h), arguments(expr)),
270+
map(x -> delay_to_function(x, iv, sts, ps, h; history_arg), arguments(expr)),
268271
metadata(expr))
269272
else
270273
return expr

0 commit comments

Comments
 (0)