Skip to content

Commit d4f7e8a

Browse files
fix: handle observeds in get_all_timeseries_indexes for split = false systems
1 parent 57e1a43 commit d4f7e8a

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/systems/abstractsystem.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -770,11 +770,19 @@ for traitT in [
770770
is_variable(sys, operation(s)(get_iv(sys)))
771771
# DDEs case, to detect x(t - k)
772772
push!(ts_idxs, ContinuousTimeseries())
773-
elseif has_index_cache(sys) && (ic = get_index_cache(sys)) !== nothing
774-
if (ts = get(ic.observed_syms_to_timeseries, s, nothing)) !== nothing
775-
union!(ts_idxs, ts)
776-
elseif (ts = get(ic.dependent_pars_to_timeseries, s, nothing)) !== nothing
777-
union!(ts_idxs, ts)
773+
else
774+
if has_index_cache(sys) && (ic = get_index_cache(sys)) !== nothing
775+
if (ts = get(ic.observed_syms_to_timeseries, s, nothing)) !== nothing
776+
union!(ts_idxs, ts)
777+
elseif (ts = get(ic.dependent_pars_to_timeseries, s, nothing)) !==
778+
nothing
779+
union!(ts_idxs, ts)
780+
end
781+
else
782+
# for split=false systems
783+
if has_observed_with_lhs(sys, sym)
784+
push!(ts_idxs, ContinuousTimeseries())
785+
end
778786
end
779787
end
780788
end

test/symbolic_indexing_interface.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,14 @@ end
213213
prob = ODEProblem(sys, [], (0.0, 1.0))
214214
@test prob.ps[b] == prob.ps[:b]
215215
end
216+
217+
@testset "`get_all_timeseries_indexes` with non-split systems" begin
218+
@variables x(t) y(t) z(t)
219+
@parameters a
220+
@named sys = ODESystem([D(x) ~ a * x, y ~ 2x, z ~ 0.0], t)
221+
sys = structural_simplify(sys, split = false)
222+
for sym in [x, y, z, x + y, x + a, y / x]
223+
@test only(get_all_timeseries_indexes(sys, sym)) == ContinuousTimeseries()
224+
end
225+
@test isempty(get_all_timeseries_indexes(sys, a))
226+
end

0 commit comments

Comments
 (0)