Skip to content

Commit 8a81e9b

Browse files
vyuduAayushSabharwal
authored andcommitted
fix compile condition error
1 parent f0b1913 commit 8a81e9b

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

src/systems/callbacks.jl

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -586,18 +586,11 @@ Base.isempty(cb::AbstractCallback) = isempty(cb.conditions)
586586
compile_condition(cb::AbstractCallback, sys, dvs, ps; expression, kwargs...)
587587
588588
Returns a function `condition(u,t,integrator)`, condition(out,u,t,integrator)` returning the `condition(cb)`.
589-
590-
Notes
591-
592-
- `expression = Val{true}`, causes the generated function to be returned as an expression.
593-
If set to `Val{false}` a `RuntimeGeneratedFunction` will be returned.
594-
- `kwargs` are passed through to `Symbolics.build_function`.
595589
"""
596-
function compile_condition(
597-
cbs::Union{AbstractCallback, Vector{<:AbstractCallback}}, sys, dvs, ps;
598-
expression = Val{false}, eval_expression = false, eval_module = @__MODULE__, kwargs...)
599-
u = map(x -> time_varying_as_func(value(x), sys), dvs)
600-
p = map.(x -> time_varying_as_func(value(x), sys), reorder_parameters(sys, ps))
590+
function compile_condition(cbs::Union{AbstractCallback, Vector{<:AbstractCallback}}, sys, dvs, ps;
591+
eval_expression = false, eval_module = @__MODULE__, kwargs...)
592+
u = map(value, dvs)
593+
p = map.(value, reorder_parameters(sys, ps))
601594
t = get_iv(sys)
602595
condit = conditions(cbs)
603596
cs = collect_constants(condit)
@@ -612,22 +605,16 @@ function compile_condition(
612605
[condit.lhs - condit.rhs]
613606
end
614607

615-
fs = build_function_wrapper(sys,
616-
condit, u, p..., t; expression,
617-
kwargs...)
618-
619-
if expression == Val{false}
620-
fs = eval_or_rgf.(fs; eval_expression, eval_module)
621-
end
622-
f_oop, f_iip = is_discrete(cbs) ? (fs, nothing) : fs # no iip function for discrete condition.
608+
fs = build_function_wrapper(sys, condit, u, p..., t; kwargs..., expression = Val{false}, cse = false)
609+
(f_oop, f_iip) = is_discrete(cbs) ? (fs, nothing) : fs
623610

624611
cond = if cbs isa AbstractVector
625612
(out, u, t, integ) -> f_iip(out, u, parameter_values(integ), t)
626613
elseif is_discrete(cbs)
627614
(u, t, integ) -> f_oop(u, parameter_values(integ), t)
628615
else
629616
function (u, t, integ)
630-
if DiffEqBase.isinplace(integ.sol.prob)
617+
if DiffEqBase.isinplace(SciMLBase.get_sol(integ).prob)
631618
tmp, = DiffEqBase.get_tmp_cache(integ)
632619
f_iip(tmp, u, parameter_values(integ), t)
633620
tmp[1]
@@ -807,13 +794,6 @@ Returns a function that takes an integrator as argument and modifies the state w
807794
affect. The generated function has the signature `affect!(integrator)`.
808795
809796
Notes
810-
811-
- `expression = Val{true}`, causes the generated function to be returned as an expression.
812-
If set to `Val{false}` a `RuntimeGeneratedFunction` will be returned.
813-
- `outputidxs`, a vector of indices of the output variables which should correspond to
814-
`unknowns(sys)`. If provided, checks that the LHS of affect equations are variables are
815-
dropped, i.e. it is assumed these indices are correct and affect equations are
816-
well-formed.
817797
- `kwargs` are passed through to `Symbolics.build_function`.
818798
"""
819799
function compile_affect(

0 commit comments

Comments
 (0)