Skip to content

Commit 33254f3

Browse files
authored
Merge pull request #974 from SciML/tests___update___mtk_indexing_tests
Update upstream mtk tests
2 parents caf6cbb + 9f69a96 commit 33254f3

File tree

6 files changed

+458
-381
lines changed

6 files changed

+458
-381
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
7676
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
7777
SciMLNLSolve = "e9a6253c-8580-4d32-9898-8661bb511710"
7878
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
79+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
7980
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
8081
SteadyStateDiffEq = "9672c7b4-1e72-59bd-8a11-6ac3964bc41f"
8182
StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
@@ -84,4 +85,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
8485
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
8586

8687
[targets]
87-
test = ["BifurcationKit", "DiffEqCallbacks", "DomainSets", "Graphviz_jll", "HomotopyContinuation", "Logging", "NonlinearSolve", "OrdinaryDiffEq", "Plots", "Random", "SafeTestsets", "SciMLBase", "SciMLNLSolve", "StableRNGs", "Statistics", "SteadyStateDiffEq", "StochasticDiffEq", "StructuralIdentifiability", "Test", "Unitful"]
88+
test = ["BifurcationKit", "DiffEqCallbacks", "DomainSets", "Graphviz_jll", "HomotopyContinuation", "Logging", "NonlinearSolve", "OrdinaryDiffEq", "Plots", "Random", "SafeTestsets", "SciMLBase", "SciMLNLSolve", "StableRNGs", "StaticArrays", "Statistics", "SteadyStateDiffEq", "StochasticDiffEq", "StructuralIdentifiability", "Test", "Unitful"]

test/extensions/homotopy_continuation.jl

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,32 @@ let
2525
u0 = [:X1 => 2.0, :X2 => 2.0, :X3 => 2.0, :X2_2X3 => 2.0]
2626

2727
# Computes the single steady state, checks that when given to the ODE rhs, all are evaluated to 0.
28-
hc_ss = hc_steady_states(rs, ps; u0=u0, show_progress=false)
28+
hc_ss = hc_steady_states(rs, ps; u0 = u0, show_progress = false, seed = 0x000004d1)
2929
hc_ss = Pair.(unknowns(rs), hc_ss[1])
30-
@test maximum(abs.(f_eval(rs, hc_ss, ps, 0.0))) 0.0 atol=1e-12
30+
@test maximum(abs.(f_eval(rs, hc_ss, ps, 0.0))) 0.0 atol = 1e-12
3131

3232
# Checks that not giving a `u0` argument yields an error for systems with conservation laws.
33-
@test_throws Exception hc_steady_states(rs, ps; show_progress=false)
33+
@test_throws Exception hc_steady_states(rs, ps; show_progress = false)
3434
end
3535

3636
# Tests for network with multiple steady state.
3737
# Tests for Symbol parameter input.
38-
# Tests that passing kwargs to HC.solve does not error.
38+
# Tests that passing kwargs to HC.solve does not error and have an effect (i.e. modifying the seed
39+
# slightly modified the output in some way).
3940
let
4041
wilhelm_2009_model = @reaction_network begin
4142
k1, Y --> 2X
4243
k2, 2X --> X + Y
4344
k3, X + Y --> Y
4445
k4, X --> 0
4546
end
46-
ps = [:k3 => 1.0, :k2 => 2.0, :k4 => 1.5, :k1=>8.0]
47+
ps = [:k3 => 1.0, :k2 => 2.0, :k4 => 1.5, :k1 => 8.0]
4748

48-
hc_ss_1 = hc_steady_states(wilhelm_2009_model, ps; seed=0x000004d1, show_progress=false)
49-
@test sort(hc_ss_1, by=sol->sol[1]) [[0.0, 0.0], [0.5, 2.0], [4.5, 6.0]]
49+
hc_ss_1 = hc_steady_states(wilhelm_2009_model, ps; seed = 0x000004d1, show_progress = false)
50+
@test sort(hc_ss_1, by = sol->sol[1]) [[0.0, 0.0], [0.5, 2.0], [4.5, 6.0]]
5051

51-
hc_ss_2 = hc_steady_states(wilhelm_2009_model, ps; seed=0x000004d2, show_progress=false)
52-
hc_ss_3 = hc_steady_states(wilhelm_2009_model, ps; seed=0x000004d2, show_progress=false)
52+
hc_ss_2 = hc_steady_states(wilhelm_2009_model, ps; seed = 0x000004d2, show_progress = false)
53+
hc_ss_3 = hc_steady_states(wilhelm_2009_model, ps; seed = 0x000004d2, show_progress = false)
5354
@test hc_ss_1 != hc_ss_2
5455
@test hc_ss_2 == hc_ss_3
5556
end
@@ -69,7 +70,7 @@ let
6970
ps = (:kY1 => 1.0, :kY2 => 3, :kZ1 => 1.0, :kZ2 => 4.0)
7071
u0_1 = (:Y1 => 1.0, :Y2 => 3, :Z1 => 10, :Z2 =>40.0)
7172

72-
ss_1 = sort(hc_steady_states(rs_1, ps; u0=u0_1, show_progress=false), by=sol->sol[1])
73+
ss_1 = sort(hc_steady_states(rs_1, ps; u0 = u0_1, show_progress = false, seed = 0x000004d1), by = sol->sol[1])
7374
@test ss_1 [[0.2, 0.1, 3.0, 1.0, 40.0, 10.0]]
7475

7576
rs_2 = @reaction_network begin
@@ -81,7 +82,7 @@ let
8182
end
8283
u0_2 = [:B2 => 1.0, :B1 => 3.0, :A2 => 10.0, :A1 =>40.0]
8384

84-
ss_2 = sort(hc_steady_states(rs_2, ps; u0=u0_2, show_progress=false), by=sol->sol[1])
85+
ss_2 = sort(hc_steady_states(rs_2, ps; u0 = u0_2, show_progress = false, seed = 0x000004d1), by = sol->sol[1])
8586
@test ss_1 ss_2
8687
end
8788

@@ -96,14 +97,15 @@ let
9697
d, X --> 0
9798
end
9899
ps = [:v => 5.0, :K => 2.5, :n => 3, :d => 1.0]
99-
sss = hc_steady_states(rs, ps; filter_negative=false, show_progress=false)
100+
sss = hc_steady_states(rs, ps; filter_negative = false, show_progress = false, seed = 0x000004d1)
100101

101102
@test length(sss) == 4
102103
for ss in sss
103-
@test f_eval(rs,sss[1], last.(ps), 0.0)[1] 0.0 atol=1e-12
104+
@test f_eval(rs,sss[1], last.(ps), 0.0)[1] 0.0 atol = 1e-12
104105
end
105106

106-
@test_throws Exception hc_steady_states(rs, [:v => 5.0, :K => 2.5, :n => 2.7, :d => 1.0]; show_progress=false)
107+
ps = [:v => 5.0, :K => 2.5, :n => 2.7, :d => 1.0]
108+
@test_throws Exception hc_steady_states(rs, ps; show_progress = false, seed = 0x000004d1)
107109
end
108110

109111

@@ -124,7 +126,7 @@ let
124126

125127
# Checks that homotopy continuation correctly find the system's single steady state.
126128
ps = [:p => 2.0, :d => 1.0, :k => 5.0]
127-
hc_ss = hc_steady_states(rs, ps)
129+
hc_ss = hc_steady_states(rs, ps; show_progress = false, seed = 0x000004d1)
128130
@test hc_ss [[2.0, 0.2, 10.0]]
129131
end
130132

@@ -137,7 +139,7 @@ let
137139
p_start = [:p => 1.0, :d => 0.2]
138140

139141
# Computes bifurcation diagram.
140-
@test_throws Exception hc_steady_states(incomplete_network, p_start)
142+
@test_throws Exception hc_steady_states(incomplete_network, p_start; show_progress = false, seed = 0x000004d1)
141143
end
142144

143145
# Tests that non-autonomous system throws an error
@@ -146,5 +148,5 @@ let
146148
(k,t), 0 <--> X
147149
end
148150
ps = [:k => 1.0]
149-
@test_throws Exception hc_steady_states(rs, ps)
151+
@test_throws Exception hc_steady_states(rs, ps; show_progress = false, seed = 0x000004d1)
150152
end

test/extensions/structural_identifiability.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ end
316316
### Other Tests ###
317317

318318
# Checks that identifiability can be assessed for coupled CRN/DAE systems.
319+
# `remove_conserved = false` is used to remove info print statement from log.
319320
let
320321
rs = @reaction_network begin
321322
@parameters k c1 c2
@@ -329,19 +330,20 @@ let
329330
@unpack p, d, k, c1, c2 = rs
330331

331332
# Tests identifiability assessment when all unknowns are measured.
332-
gi_1 = assess_identifiability(rs; measured_quantities = [:X, :V, :C], loglevel)
333-
li_1 = assess_local_identifiability(rs; measured_quantities = [:X, :V, :C], loglevel)
334-
ifs_1 = find_identifiable_functions(rs; measured_quantities = [:X, :V, :C], loglevel)
333+
remove_conserved = false
334+
gi_1 = assess_identifiability(rs; measured_quantities = [:X, :V, :C], loglevel, remove_conserved)
335+
li_1 = assess_local_identifiability(rs; measured_quantities = [:X, :V, :C], loglevel, remove_conserved)
336+
ifs_1 = find_identifiable_functions(rs; measured_quantities = [:X, :V, :C], loglevel, remove_conserved)
335337
@test sym_dict(gi_1) == Dict([:X => :globally, :C => :globally, :V => :globally, :k => :globally,
336338
:c1 => :nonidentifiable, :c2 => :nonidentifiable, :p => :globally, :d => :globally])
337339
@test sym_dict(li_1) == Dict([:X => 1, :C => 1, :V => 1, :k => 1, :c1 => 0, :c2 => 0, :p => 1, :d => 1])
338340
@test issetequal(ifs_1, [d, p, k, c1 + c2])
339341

340342
# Tests identifiability assessment when only variables are measured.
341343
# Checks that a parameter in an equation can be set as known.
342-
gi_2 = assess_identifiability(rs; measured_quantities = [:V, :C], known_p = [:c1], loglevel)
343-
li_2 = assess_local_identifiability(rs; measured_quantities = [:V, :C], known_p = [:c1], loglevel)
344-
ifs_2 = find_identifiable_functions(rs; measured_quantities = [:V, :C], known_p = [:c1], loglevel)
344+
gi_2 = assess_identifiability(rs; measured_quantities = [:V, :C], known_p = [:c1], loglevel, remove_conserved)
345+
li_2 = assess_local_identifiability(rs; measured_quantities = [:V, :C], known_p = [:c1], loglevel, remove_conserved)
346+
ifs_2 = find_identifiable_functions(rs; measured_quantities = [:V, :C], known_p = [:c1], loglevel, remove_conserved)
345347
@test sym_dict(gi_2) == Dict([:X => :nonidentifiable, :C => :globally, :V => :globally, :k => :nonidentifiable,
346348
:c1 => :globally, :c2 => :nonidentifiable, :p => :nonidentifiable, :d => :globally])
347349
@test sym_dict(li_2) == Dict([:X => 0, :C => 1, :V => 1, :k => 0, :c1 => 1, :c2 => 0, :p => 0, :d => 1])

test/simulation_and_solving/solve_nonlinear.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ let
9090
# Creates NonlinearProblem.
9191
u0 = [steady_state_network_3.X => rand(), steady_state_network_3.Y => rand() + 1.0, steady_state_network_3.Y2 => rand() + 3.0, steady_state_network_3.XY2 => 0.0]
9292
p = [:p => rand()+1.0, :d => 0.5, :k1 => 1.0, :k2 => 2.0, :k3 => 3.0, :k4 => 4.0]
93-
nl_prob_1 = NonlinearProblem(steady_state_network_3, u0, p; remove_conserved = true)
93+
nl_prob_1 = NonlinearProblem(steady_state_network_3, u0, p; remove_conserved = true, remove_conserved_warn = false)
9494
nl_prob_2 = NonlinearProblem(steady_state_network_3, u0, p)
9595

9696
# Solves it using standard algorithm and simulation based algorithm.

0 commit comments

Comments
 (0)