Skip to content

Commit a309a9e

Browse files
authored
Merge pull request #1158 from sivasathyaseeelan/tests-in-reactionsystems-networkanalysis
test: added some edge cases in reactionsystem.jl and network_properties.jl
2 parents 494ee45 + 48038fe commit a309a9e

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

docs/pages.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pages = Any[
4040
"Steady state analysis" => Any[
4141
"steady_state_functionality/homotopy_continuation.md",
4242
"steady_state_functionality/nonlinear_solve.md",
43-
#"steady_state_functionality/steady_state_stability_computation.md",
43+
# "steady_state_functionality/steady_state_stability_computation.md",
4444
"steady_state_functionality/bifurcation_diagrams.md",
4545
"steady_state_functionality/dynamical_systems.md"
4646
],

test/network_analysis/crn_theory.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ let
2828
@test_throws Exception Catalyst.iscomplexbalanced(rn, k)
2929
end
3030

31+
# Test that incomplete rate maps error.
32+
let
33+
rn = @reaction_network begin
34+
(k1, k2), C1 <--> C2
35+
(k3, k4), C2 <--> C3
36+
(k5, k6), C3 <--> C1
37+
end
38+
39+
incorrect_params = Dict(:k1 => 0.5)
40+
@test_throws ErrorException Catalyst.iscomplexbalanced(rn, incorrect_params)
41+
end
42+
3143
# Tests rate matrix computation for various input types.
3244
let
3345
# Declares network and its known rate matrix.
@@ -61,6 +73,13 @@ let
6173
Catalyst.ratematrix(rn, rates_vec) == rate_mat
6274
Catalyst.ratematrix(rn, rates_tup) == rate_mat
6375
Catalyst.ratematrix(rn, rates_dict) == rate_mat
76+
77+
# Tests that throws error in rate matrix.
78+
incorrect_param_dict = Dict(:k1 => 1.0)
79+
80+
@test_throws ErrorException Catalyst.ratematrix(rn, 123)
81+
@test_throws ErrorException Catalyst.ratematrix(rn, incorrect_param_dict)
82+
6483
@test_throws Exception Catalyst.iscomplexbalanced(rn, rates_invalid)
6584
end
6685

@@ -92,6 +111,16 @@ let
92111
@test Catalyst.robustspecies(EnvZ_OmpR) == [6]
93112
end
94113

114+
let
115+
# Define a reaction network with bi-directional reactions
116+
non_deficient_network = @reaction_network begin
117+
(k1, k2), A <--> B
118+
(k3, k4), B <--> C
119+
end
120+
121+
# Test: Check that the error is raised for networks with deficiency != 1
122+
@test_throws ErrorException Catalyst.robustspecies(non_deficient_network)
123+
end
95124

96125
### Complex balance and reversibility tests ###
97126

test/reactionsystem_core/reactionsystem.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ end
107107
let
108108
@named rs2 = ReactionSystem(rxs, t)
109109
@test Catalyst.isequivalent(rs, rs2)
110+
111+
# Test with a type mismatch
112+
@test Catalyst.isequivalent(rs, "Not a ReactionSystem") == false
110113
end
111114

112115
# Defaults test.

0 commit comments

Comments
 (0)