diff --git a/src/systems/abstractsystem.jl b/src/systems/abstractsystem.jl index a350211386..38af4b986c 100644 --- a/src/systems/abstractsystem.jl +++ b/src/systems/abstractsystem.jl @@ -556,10 +556,20 @@ function SymbolicIndexingInterface.is_observed(sys::AbstractSystem, sym) end function SymbolicIndexingInterface.observed(sys::AbstractSystem, sym) - return let _fn = build_explicit_observed_function(sys, sym) - fn(u, p, t) = _fn(u, p, t) - fn(u, p::MTKParameters, t) = _fn(u, p..., t) - fn + if is_time_dependent(sys) + return let _fn = build_explicit_observed_function(sys, sym) + fn1(u, p, t) = _fn(u, p, t) + fn1(u, p::MTKParameters, t) = _fn(u, p..., t) + fn1 + end + else + return let _fn = build_explicit_observed_function(sys, sym) + fn2(u, p) = _fn(u, p) + fn2(u, p::MTKParameters) = _fn(u, p...) + fn2(::Nothing, p) = _fn([], p) + fn2(::Nothing, p::MTKParameters) = _fn([], p...) + fn2 + end end end