Skip to content

Commit 23b8f5f

Browse files
committed
fix compile condition error
1 parent 7f5d895 commit 23b8f5f

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
@@ -588,18 +588,11 @@ Base.isempty(cb::AbstractCallback) = isempty(cb.conditions)
588588
compile_condition(cb::AbstractCallback, sys, dvs, ps; expression, kwargs...)
589589
590590
Returns a function `condition(u,t,integrator)`, condition(out,u,t,integrator)` returning the `condition(cb)`.
591-
592-
Notes
593-
594-
- `expression = Val{true}`, causes the generated function to be returned as an expression.
595-
If set to `Val{false}` a `RuntimeGeneratedFunction` will be returned.
596-
- `kwargs` are passed through to `Symbolics.build_function`.
597591
"""
598-
function compile_condition(
599-
cbs::Union{AbstractCallback, Vector{<:AbstractCallback}}, sys, dvs, ps;
600-
expression = Val{false}, eval_expression = false, eval_module = @__MODULE__, kwargs...)
601-
u = map(x -> time_varying_as_func(value(x), sys), dvs)
602-
p = map.(x -> time_varying_as_func(value(x), sys), reorder_parameters(sys, ps))
592+
function compile_condition(cbs::Union{AbstractCallback, Vector{<:AbstractCallback}}, sys, dvs, ps;
593+
eval_expression = false, eval_module = @__MODULE__, kwargs...)
594+
u = map(value, dvs)
595+
p = map.(value, reorder_parameters(sys, ps))
603596
t = get_iv(sys)
604597
condit = conditions(cbs)
605598
cs = collect_constants(condit)
@@ -614,22 +607,16 @@ function compile_condition(
614607
[condit.lhs - condit.rhs]
615608
end
616609

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

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

0 commit comments

Comments
 (0)