Skip to content

Commit a795f03

Browse files
authored
Merge pull request #2057 from SciML/myb/param_idx
Add support for indexing with a parameter
2 parents 1b8b19a + 2a43185 commit a795f03

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/systems/diffeqs/odesystem.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ function build_explicit_observed_function(sys, ts;
321321

322322
sts = Set(states(sys))
323323
observed_idx = Dict(x.lhs => i for (i, x) in enumerate(obs))
324+
param_set = Set(parameters(sys))
325+
param_set_ns = Set(states(sys, p) for p in parameters(sys))
324326
namespaced_to_obs = Dict(states(sys, x.lhs) => x.lhs for x in obs)
325327
namespaced_to_sts = Dict(states(sys, x) => x for x in states(sys))
326328

@@ -329,6 +331,9 @@ function build_explicit_observed_function(sys, ts;
329331
subs = Dict()
330332
maxidx = 0
331333
for s in dep_vars
334+
if s in param_set || s in param_set_ns
335+
continue
336+
end
332337
idx = get(observed_idx, s, nothing)
333338
if idx !== nothing
334339
idx > maxidx && (maxidx = idx)

test/odesystem.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ for p in [prob_pmap, prob_dpmap]
261261
end
262262
sol_pmap = solve(prob_pmap, Rodas5())
263263
sol_dpmap = solve(prob_dpmap, Rodas5())
264+
@test all(isequal(0.05), sol_pmap.(0:10:100, idxs = k₁))
264265

265266
@test sol_pmap.u sol_dpmap.u
266267

0 commit comments

Comments
 (0)