@@ -44,9 +44,11 @@ function as_diffeq_array(vt::Vector{VectorTemplate}, t)
4444 return DiffEqArray (typeof (TupleOfArraysWrapper (vt))[], t, (1 , 1 ))
4545end
4646
47- function is_empty_indp (indp)
48- isempty (variable_symbols (indp)) && isempty (parameter_symbols (indp)) &&
49- isempty (independent_variable_symbols (indp))
47+ function get_root_indp (indp)
48+ if hasmethod (symbolic_container, Tuple{typeof (indp)}) && (sc = symbolic_container (indp)) != = indp
49+ return get_root_indp (sc)
50+ end
51+ return indp
5052end
5153
5254# Everything from this point on is public API
@@ -107,28 +109,19 @@ end
107109
108110SavedSubsystem (indp, pobj, :: Nothing ) = nothing
109111
110- function SavedSubsystem (indp, pobj, saved_idxs:: Vector{Int} )
111- isempty (saved_idxs) && return nothing
112- isempty (variable_symbols (indp)) && return nothing
113- state_map = Dict {Int, Int} (k => v for (k, v) in enumerate (saved_idxs))
114- return SavedSubsystem (state_map, nothing , nothing , nothing , nothing , nothing , nothing )
115- end
116-
117112function SavedSubsystem (indp, pobj, idx:: Int )
118113 state_map = Dict (1 => idx)
119114 return SavedSubsystem (state_map, nothing , nothing , nothing , nothing , nothing , nothing )
120115end
121116
122- function SavedSubsystem (indp, pobj, saved_idxs)
123- # nothing saved
124- if saved_idxs === nothing || isempty (saved_idxs)
117+ function SavedSubsystem (indp, pobj, saved_idxs:: Union{Array, Tuple} )
118+ _indp = get_root_indp (indp)
119+ if indp === EMPTY_SYMBOLCACHE || indp === nothing
125120 return nothing
126121 end
127-
128- # this is required because problems with no system have an empty `SymbolCache`
129- # as their symbolic container.
130- if is_empty_indp (indp)
131- return nothing
122+ if eltype (saved_idxs) == Int
123+ state_map = Dict {Int, Int} (k => v for (k, v) in enumerate (saved_idxs))
124+ return SavedSubsystem (state_map, nothing , nothing , nothing , nothing , nothing , nothing )
132125 end
133126
134127 # array state symbolics must be scalarized
@@ -380,7 +373,7 @@ function get_save_idxs_and_saved_subsystem(prob, save_idx::Int)
380373end
381374function get_save_idxs_and_saved_subsystem (prob, save_idxs)
382375 if ! (save_idxs isa AbstractArray) || symbolic_type (save_idxs) != NotSymbolic ()
383- _save_idxs = [ save_idxs]
376+ _save_idxs = ( save_idxs,)
384377 else
385378 _save_idxs = save_idxs
386379 end
0 commit comments