Skip to content

Commit

Permalink
refactor: fix SII for Symbol fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Nov 15, 2023
1 parent e069fd8 commit ce7e82a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/systems/abstractsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ce7e82a

Please sign in to comment.