Skip to content

Commit 0f47554

Browse files
Added some edge cases in reactionsystems and networkanalysis
Signed-off-by: sivasathyaseeelan <[email protected]>
1 parent f4a0b0c commit 0f47554

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

test/network_analysis/network_properties.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,17 @@ let
180180
rates = Dict(zip(parameters(rn4), k))
181181
@test Catalyst.iscomplexbalanced(rn4, rates) == true
182182
end
183+
184+
let
185+
rn = @reaction_network begin
186+
(k1, k2), C1 <--> C2
187+
(k3, k4), C2 <--> C3
188+
(k5, k6), C3 <--> C1
189+
end
190+
191+
incorrect_params = Dict(:k1 => 0.5)
192+
@test_throws ErrorException Catalyst.iscomplexbalanced(rn, incorrect_params)
193+
end
183194

184195
### Tests Reversibility ###
185196

@@ -708,6 +719,13 @@ let
708719
Catalyst.ratematrix(rn, rates_vec) == rate_mat
709720
Catalyst.ratematrix(rn, rates_tup) == rate_mat
710721
Catalyst.ratematrix(rn, rates_dict) == rate_mat
722+
723+
# Tests that throws error in rate matrix.
724+
incorrect_param_dict = Dict(:k1 => 1.0)
725+
726+
@test_throws ErrorException Catalyst.ratematrix(rn, 123)
727+
@test_throws ErrorException Catalyst.ratematrix(rn, incorrect_param_dict)
728+
711729
@test_throws Exception Catalyst.iscomplexbalanced(rn, rates_invalid)
712730
end
713731

@@ -739,6 +757,17 @@ let
739757
@test Catalyst.robustspecies(EnvZ_OmpR) == [6]
740758
end
741759

760+
let
761+
# Define a reaction network with bi-directional reactions
762+
non_deficient_network = @reaction_network begin
763+
(k1, k2), A <--> B
764+
(k3, k4), B <--> C
765+
end
766+
767+
# Test: Check that the error is raised for networks with deficiency != 1
768+
@test_throws ErrorException Catalyst.robustspecies(non_deficient_network)
769+
end
770+
742771

743772
### Complex and detailed balance tests
744773

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)