Skip to content

Commit

Permalink
Merge pull request #1158 from sivasathyaseeelan/tests-in-reactionsyst…
Browse files Browse the repository at this point in the history
…ems-networkanalysis

test: added some edge cases in reactionsystem.jl and network_properties.jl
  • Loading branch information
vyudu authored Jan 9, 2025
2 parents 494ee45 + 48038fe commit a309a9e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pages = Any[
"Steady state analysis" => Any[
"steady_state_functionality/homotopy_continuation.md",
"steady_state_functionality/nonlinear_solve.md",
#"steady_state_functionality/steady_state_stability_computation.md",
# "steady_state_functionality/steady_state_stability_computation.md",
"steady_state_functionality/bifurcation_diagrams.md",
"steady_state_functionality/dynamical_systems.md"
],
Expand Down
29 changes: 29 additions & 0 deletions test/network_analysis/crn_theory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ let
@test_throws Exception Catalyst.iscomplexbalanced(rn, k)
end

# Test that incomplete rate maps error.
let
rn = @reaction_network begin
(k1, k2), C1 <--> C2
(k3, k4), C2 <--> C3
(k5, k6), C3 <--> C1
end

incorrect_params = Dict(:k1 => 0.5)
@test_throws ErrorException Catalyst.iscomplexbalanced(rn, incorrect_params)
end

# Tests rate matrix computation for various input types.
let
# Declares network and its known rate matrix.
Expand Down Expand Up @@ -61,6 +73,13 @@ let
Catalyst.ratematrix(rn, rates_vec) == rate_mat
Catalyst.ratematrix(rn, rates_tup) == rate_mat
Catalyst.ratematrix(rn, rates_dict) == rate_mat

# Tests that throws error in rate matrix.
incorrect_param_dict = Dict(:k1 => 1.0)

@test_throws ErrorException Catalyst.ratematrix(rn, 123)
@test_throws ErrorException Catalyst.ratematrix(rn, incorrect_param_dict)

@test_throws Exception Catalyst.iscomplexbalanced(rn, rates_invalid)
end

Expand Down Expand Up @@ -92,6 +111,16 @@ let
@test Catalyst.robustspecies(EnvZ_OmpR) == [6]
end

let
# Define a reaction network with bi-directional reactions
non_deficient_network = @reaction_network begin
(k1, k2), A <--> B
(k3, k4), B <--> C
end

# Test: Check that the error is raised for networks with deficiency != 1
@test_throws ErrorException Catalyst.robustspecies(non_deficient_network)
end

### Complex balance and reversibility tests ###

Expand Down
3 changes: 3 additions & 0 deletions test/reactionsystem_core/reactionsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ end
let
@named rs2 = ReactionSystem(rxs, t)
@test Catalyst.isequivalent(rs, rs2)

# Test with a type mismatch
@test Catalyst.isequivalent(rs, "Not a ReactionSystem") == false
end

# Defaults test.
Expand Down

0 comments on commit a309a9e

Please sign in to comment.