Skip to content

Commit da19258

Browse files
fix: fix Pre parameter discovery for AffectSystem
1 parent 06fcfe4 commit da19258

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/systems/callbacks.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,17 @@ function make_affect(affect::Vector{Equation}; discrete_parameters = Any[],
285285

286286
dvs = OrderedSet()
287287
params = OrderedSet()
288+
_varsbuf = Set()
288289
for eq in affect
289290
if !haspre(eq) && !(symbolic_type(eq.rhs) === NotSymbolic() ||
290291
symbolic_type(eq.lhs) === NotSymbolic())
291292
@warn "Affect equation $eq has no `Pre` operator. As such it will be interpreted as an algebraic equation to be satisfied after the callback. If you intended to use the value of a variable x before the affect, use Pre(x). Errors may be thrown if there is no `Pre` and the algebraic equation is unsatisfiable, such as X ~ X + 1."
292293
end
293294
collect_vars!(dvs, params, eq, iv; op = Pre)
295+
empty!(_varsbuf)
296+
vars!(_varsbuf, eq; op = Pre)
297+
filter!(x -> iscall(x) && operation(x) isa Pre, _varsbuf)
298+
union!(params, _varsbuf)
294299
diffvs = collect_applied_operators(eq, Differential)
295300
union!(dvs, diffvs)
296301
end

0 commit comments

Comments
 (0)