@@ -44,9 +44,11 @@ function as_diffeq_array(vt::Vector{VectorTemplate}, t)
44
44
return DiffEqArray (typeof (TupleOfArraysWrapper (vt))[], t, (1 , 1 ))
45
45
end
46
46
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
50
52
end
51
53
52
54
# Everything from this point on is public API
@@ -107,28 +109,19 @@ end
107
109
108
110
SavedSubsystem (indp, pobj, :: Nothing ) = nothing
109
111
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
-
117
112
function SavedSubsystem (indp, pobj, idx:: Int )
118
113
state_map = Dict (1 => idx)
119
114
return SavedSubsystem (state_map, nothing , nothing , nothing , nothing , nothing , nothing )
120
115
end
121
116
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
125
120
return nothing
126
121
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 )
132
125
end
133
126
134
127
# array state symbolics must be scalarized
@@ -380,7 +373,7 @@ function get_save_idxs_and_saved_subsystem(prob, save_idx::Int)
380
373
end
381
374
function get_save_idxs_and_saved_subsystem (prob, save_idxs)
382
375
if ! (save_idxs isa AbstractArray) || symbolic_type (save_idxs) != NotSymbolic ()
383
- _save_idxs = [ save_idxs]
376
+ _save_idxs = ( save_idxs,)
384
377
else
385
378
_save_idxs = save_idxs
386
379
end
0 commit comments