Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: added some edge cases in reactionsystem.jl and network_properties.jl #1158

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions test/network_analysis/network_properties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,17 @@ let
rates = Dict(zip(parameters(rn4), k))
@test Catalyst.iscomplexbalanced(rn4, rates) == true
end

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 Reversibility ###

Expand Down Expand Up @@ -708,6 +719,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 @@ -739,6 +757,17 @@ 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 and detailed balance 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
Loading