From aa3f0bab64fe719b6d5662cb41992b64c8faa72d Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Fri, 24 May 2024 18:40:27 +0530 Subject: [PATCH] fixup! feat: add `SII.observed` support for `AbstractSystem` --- src/systems/abstractsystem.jl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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