diff --git a/src/systems/abstractsystem.jl b/src/systems/abstractsystem.jl index 2798349ae6..b701f3c821 100644 --- a/src/systems/abstractsystem.jl +++ b/src/systems/abstractsystem.jl @@ -2600,8 +2600,10 @@ end keytype(::Type{<:Pair{T, V}}) where {T, V} = T function Symbolics.substitute(sys::AbstractSystem, rules::Union{Vector{<:Pair}, Dict}) - if has_continuous_domain(sys) && get_continuous_events(sys) !== nothing || - has_discrete_events(sys) && get_discrete_events(sys) !== nothing + if has_continuous_domain(sys) && get_continuous_events(sys) !== nothing && + !isempty(get_continuous_events(sys)) || + has_discrete_events(sys) && get_discrete_events(sys) !== nothing && + !isempty(get_discrete_events(sys)) @warn "`substitute` only supports performing substitutions in equations. This system has events, which will not be updated." end if keytype(eltype(rules)) <: Symbol diff --git a/test/odesystem.jl b/test/odesystem.jl index d54baa8a93..68c50d4d7f 100644 --- a/test/odesystem.jl +++ b/test/odesystem.jl @@ -972,7 +972,8 @@ vars_sub2 = @variables s2(t) @named partial_sub = ODESystem(Equation[], t, vars_sub2, []) @named sub = extend(partial_sub, sub) -new_sys2 = complete(substitute(sys2, Dict(:sub => sub))) +# no warnings for systems without events +new_sys2 = @test_nowarn complete(substitute(sys2, Dict(:sub => sub))) Set(unknowns(new_sys2)) == Set([new_sys2.x1, new_sys2.sys1.x1, new_sys2.sys1.sub.s1, new_sys2.sys1.sub.s2, new_sys2.sub.s1, new_sys2.sub.s2])