Skip to content

Commit 9fa8ffd

Browse files
authored
Merge pull request #1270 from SciML/improve_sol_indexing_in_tests
Update missing test symbolic indexing of solutions
2 parents 3b394e5 + 4031c43 commit 9fa8ffd

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

test/reactionsystem_core/coupled_equation_crn_systems.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ let
4747
# Checks that the correct steady state is found through ODEProblem.
4848
oprob = ODEProblem(coupled_rs, u0, tspan, ps)
4949
osol = solve(oprob, Vern7(); abstol = 1e-8, reltol = 1e-8)
50-
@test osol.u[end] [2.0, 1.0]
50+
@test osol[[X,A]][end] [2.0, 1.0]
5151

5252
# Checks that the correct steady state is found through NonlinearProblem.
5353
nlprob = NonlinearProblem(coupled_rs, u0, ps)
5454
nlsol = solve(nlprob; abstol = 1e-8, reltol = 1e-8)
55-
@test nlsol [2.0, 1.0]
55+
@test nlsol[[X,A]] [2.0, 1.0]
5656

5757
# Checks that the correct steady state is found through SteadyStateProblem.
5858
ssprob = SteadyStateProblem(coupled_rs, u0, ps)
5959
sssol = solve(ssprob, DynamicSS(Rosenbrock23()); abstol = 1e-8, reltol = 1e-8)
60-
@test sssol [2.0, 1.0]
60+
@test sssol[[X,A]] [2.0, 1.0]
6161
end
6262

6363
# Checks that coupled systems created via the DSL, extension, and programmatically are identical.
@@ -116,7 +116,7 @@ let
116116
for coupled_rs in [coupled_rs_prog, coupled_rs_extended, coupled_rs_dsl]
117117
oprob = ODEProblem(coupled_rs, u0, tspan, ps)
118118
osol = solve(oprob, Vern7(); abstol = 1e-8, reltol = 1e-8)
119-
osol.u[end] [10.0, 10.0, 11.0, 11.0]
119+
osol[[A,B,X1,X2]][end] [10.0, 10.0, 11.0, 11.0]
120120
end
121121
end
122122

@@ -158,10 +158,10 @@ let
158158
@test_throws Exception SteadyStateProblem(coupled_rs, u0, ps)
159159

160160
# Checks that the correct steady state is found through ODEProblem.
161-
oprob = ODEProblem(coupled_rs, u0, tspan, ps; structural_simplify = true,
161+
oprob = ODEProblem(coupled_rs, u0, tspan, ps; structural_simplify = true,
162162
guesses = [A => 1.0])
163163
osol = solve(oprob, Rosenbrock23(); abstol = 1e-8, reltol = 1e-8)
164-
@test osol.u[end] [2.0, 3.0]
164+
@test osol[[X,A]][end] [2.0, 3.0]
165165

166166
# Checks that the correct steady state is found through NonlinearProblem.
167167
u0 = [X => 0.1, A => 16.1/2]
@@ -171,10 +171,10 @@ let
171171

172172
# Checks that the correct steady state is found through SteadyStateProblem.
173173
u0 = [X => 0.1]
174-
ssprob = SteadyStateProblem(coupled_rs, u0, ps; structural_simplify = true,
174+
ssprob = SteadyStateProblem(coupled_rs, u0, ps; structural_simplify = true,
175175
guesses = [A => 1.0])
176176
sssol = solve(ssprob, DynamicSS(Rosenbrock23()); abstol = 1e-8, reltol = 1e-8)
177-
@test sssol [2.0, 3.0]
177+
@test sssol[[X,A]] [2.0, 3.0]
178178
end
179179

180180

@@ -206,9 +206,9 @@ let
206206

207207
# Creates and solves a ODE, SteadyState, and Nonlinear problems.
208208
# Success is tested by checking that the same steady state solution is found.
209-
oprob = ODEProblem(coupled_rs, u0, (0.0, 1000.0), ps; structural_simplify = true,
209+
oprob = ODEProblem(coupled_rs, u0, (0.0, 1000.0), ps; structural_simplify = true,
210210
warn_initialize_determined = false)
211-
ssprob = SteadyStateProblem(coupled_rs, u0, ps; structural_simplify = true,
211+
ssprob = SteadyStateProblem(coupled_rs, u0, ps; structural_simplify = true,
212212
warn_initialize_determined = false)
213213
nlprob = NonlinearProblem(coupled_rs, u0, ps)
214214
osol = solve(oprob, Rosenbrock23(); abstol = 1e-8, reltol = 1e-8)
@@ -286,15 +286,15 @@ let
286286
@named coupled_rs = ReactionSystem(eqs, τ)
287287
coupled_rs = complete(coupled_rs)
288288

289-
# Checks that systems created from coupled reaction systems contain the correct content
289+
# Checks that systems created from coupled reaction systems contain the correct content
290290
osys = convert(ODESystem, coupled_rs)
291291
ssys = convert(SDESystem, coupled_rs)
292292
nlsys = convert(NonlinearSystem, coupled_rs)
293293
initps = Initial.((X, X2, A, B))
294294
fullps = union(initps, [k1, k2, k, b1, b2])
295295
for sys in [coupled_rs, osys, ssys, nlsys]
296296
@test issetequal(parameters(sys), [k1, k2, k, b1, b2])
297-
@test issetequal(unknowns(sys), [A, B, X, X2])
297+
@test issetequal(unknowns(sys), [A, B, X, X2])
298298
end
299299
end
300300

@@ -1011,7 +1011,7 @@ let
10111011
end
10121012

10131013
# Complicated differential.
1014-
@test_throws Exception @eval @reaction_network begin
1014+
@test_throws Exception @eval @reaction_network begin
10151015
@equations V + X^2 ~ 1.0 - D(V + log(1 + X))
10161016
d, X --> 0
10171017
end

test/reactionsystem_core/reactionsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ let
322322
for rs in [rs_prog, rs_dsl], u0 in u0_alts, p in ps_alts
323323
oprob_remade = remake(oprob; u0, p)
324324
sol = solve(oprob_remade, Vern7(); abstol = 1e-8, reltol = 1e-8)
325-
@test sol.u[end] [0.5, 5.0, 0.2, 2.5]
325+
@test sol[[X[1], X[2], Y1 ,Y2]][end] [0.5, 5.0, 0.2, 2.5]
326326
end
327327
end
328328
end

0 commit comments

Comments
 (0)