Skip to content

Commit 1b59fd2

Browse files
test: make ensemble multi prob test independent of variable order
1 parent cc3c3fe commit 1b59fd2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/downstream/ensemble_multi_prob.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using ModelingToolkit, OrdinaryDiffEq, Test
2+
using SymbolicIndexingInterface
23
using ModelingToolkit: t_nounits as t, D_nounits as D
34
@variables x(t), y(t)
45

@@ -16,10 +17,12 @@ prob3 = ODEProblem(sys3, [3.0, 3.0], (0.0, 1.0))
1617
# test that when passing a vector of problems, trajectories and the prob_func are chosen appropriately
1718
ensemble_prob = EnsembleProblem([prob1, prob2, prob3])
1819
sol = solve(ensemble_prob, Tsit5(), EnsembleThreads())
20+
xidx = variable_index(sys1, x)
21+
yidx = variable_index(sys1, y)
1922
for i in 1:3
20-
@test sol[1, :, i] == sol.u[i][x]
21-
@test sol[2, :, i] == sol.u[i][y]
23+
@test sol[xidx, :, i] == sol.u[i][x]
24+
@test sol[yidx, :, i] == sol.u[i][y]
2225
end
2326
# Ensemble is a recursive array
24-
@test only.(sol(0.0, idxs = [x])) == sol[1, 1, :]
25-
@test only.(sol(1.0, idxs = [x])) [sol[i][1, end] for i in 1:3]
27+
@test only.(sol(0.0, idxs = [x])) == sol[xidx, 1, :]
28+
@test only.(sol(1.0, idxs = [x])) [sol[i][xidx, end] for i in 1:3]

0 commit comments

Comments
 (0)