Skip to content

Commit a457a02

Browse files
refactor: allow changing name of parameter argument in delay_to_function
1 parent 203088b commit a457a02

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,29 +242,30 @@ 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(sys::AbstractODESystem, eqs = full_equations(sys); history_arg = DEFAULT_PARAMS_ARG)
246247
delay_to_function(eqs,
247248
get_iv(sys),
248249
Dict{Any, Int}(operation(s) => i for (i, s) in enumerate(unknowns(sys))),
249250
parameters(sys),
250-
DDE_HISTORY_FUN)
251+
DDE_HISTORY_FUN; history_arg)
251252
end
252-
function delay_to_function(eqs::Vector, iv, sts, ps, h)
253-
delay_to_function.(eqs, (iv,), (sts,), (ps,), (h,))
253+
function delay_to_function(eqs::Vector, iv, sts, ps, h; history_arg = DEFAULT_PARAMS_ARG)
254+
delay_to_function.(eqs, (iv,), (sts,), (ps,), (h,); history_arg)
254255
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)
256+
function delay_to_function(eq::Equation, iv, sts, ps, h; history_arg = DEFAULT_PARAMS_ARG)
257+
delay_to_function(eq.lhs, iv, sts, ps, h; history_arg) ~ delay_to_function(eq.rhs, iv, sts, ps, h; history_arg)
257258
end
258-
function delay_to_function(expr, iv, sts, ps, h)
259+
function delay_to_function(expr, iv, sts, ps, h; history_arg = DEFAULT_PARAMS_ARG)
259260
if isdelay(expr, iv)
260261
v = operation(expr)
261262
time = arguments(expr)[1]
262263
idx = sts[v]
263-
return term(getindex, h(Sym{Any}(:ˍ₋arg3), time), idx, type = Real) # BIG BIG HACK
264+
return term(getindex, h(history_arg, time), idx, type = Real) # BIG BIG HACK
264265
elseif iscall(expr)
265266
return maketerm(typeof(expr),
266267
operation(expr),
267-
map(x -> delay_to_function(x, iv, sts, ps, h), arguments(expr)),
268+
map(x -> delay_to_function(x, iv, sts, ps, h; history_arg), arguments(expr)),
268269
metadata(expr))
269270
else
270271
return expr

0 commit comments

Comments
 (0)