From ce7e82abb3d5fc6f63894b61e9f482fdfc13ae3c Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Wed, 15 Nov 2023 17:03:40 +0530 Subject: [PATCH] refactor: fix SII for Symbol fallbacks --- src/systems/abstractsystem.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/systems/abstractsystem.jl b/src/systems/abstractsystem.jl index ac1213ce3a..6f0438ed88 100644 --- a/src/systems/abstractsystem.jl +++ b/src/systems/abstractsystem.jl @@ -184,10 +184,13 @@ end #Treat the result as a vector of symbols always function SymbolicIndexingInterface.is_variable(sys::AbstractSystem, sym) - issym(sym) || return false if unwrap(sym) isa Int # [x, 1] coerces 1 to a Num return unwrap(sym) in 1:length(unknown_states(sys)) end + usym = unwrap(sym) + if !(istree(usym) && (operation(usym) == getindex || !isa(operation(usym), Function))) + return false + end return any(isequal(sym), unknown_states(sys)) || is_variable(sys, getname(sym)) end @@ -221,7 +224,10 @@ function SymbolicIndexingInterface.variable_symbols(sys::AbstractSystem) end function SymbolicIndexingInterface.is_parameter(sys::AbstractSystem, sym) - issym(sym) || return false + if unwrap(sym) isa Int + return unwrap(sym) in 1:length(parameters(sys)) + end + return any(isequal(sym), parameters(sys)) || is_parameter(sys, getname(sym)) end