Skip to content

Commit b8d66aa

Browse files
committed
updates
1 parent 0c6ddd5 commit b8d66aa

File tree

7 files changed

+61
-10
lines changed

7 files changed

+61
-10
lines changed

ext/CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ end
157157
function make_osys(rs::ReactionSystem; remove_conserved=true)
158158
# Creates the ODESystem corresponding to the ReactionSystem (expanding functions and flattening it).
159159
# Creates a list of the systems all symbols (unknowns and parameters).
160-
rs = complete(Catalyst.expand_registered_functions(flatten(rs)))
160+
iscomplete(rs) || error(COMPLETENESS_ERROR)
161+
rs = Catalyst.expand_registered_functions(flatten(rs))
161162
osys = complete(convert(ODESystem, rs; remove_conserved))
162163
vars = [unknowns(rs); parameters(rs)]
163164

src/reaction_network.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ emptyrn = @reaction_network
148148
149149
ReactionSystems generated through `@reaction_network` are complete.
150150
"""
151-
# macro reaction_network(args...)
152-
# return :(complete(@network_component $(args... )))
153-
# end
154151
macro reaction_network(name::Symbol, ex::Expr)
155152
:(complete($(make_reaction_system(MacroTools.striplines(ex); name = :($(QuoteNode(name)))))))
156153
end
@@ -179,6 +176,9 @@ macro reaction_network(name::Symbol = gensym(:ReactionSystem))
179176
:(complete(ReactionSystem(Reaction[], t, [], []; name = $(QuoteNode(name))))))
180177
end
181178

179+
# Ideally, it would have been possible to combine the @reaction_network and @network_component macros.
180+
# However, this issue: https://github.com/JuliaLang/julia/issues/37691 causes problem with interpolations
181+
# if we make the @reaction_network macro call the @network_component macro.
182182
"""
183183
@network_component
184184

src/reactionsystem.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ struct ReactionSystem{V <: NetworkProperties} <:
544544
# inner constructor is considered private and may change between non-breaking releases.
545545
function ReactionSystem(eqs, rxs, iv, sivs, unknowns, spcs, ps, var_to_name, observed,
546546
name, systems, defaults, connection_type, nps, cls, cevs, devs,
547-
metadata, complete; checks::Bool = true)
547+
metadata = nothing, complete = false; checks::Bool = true)
548548

549549
# unit checks are for ODEs and Reactions only currently
550550
nonrx_eqs = Equation[eq for eq in eqs if eq isa Equation]
@@ -680,7 +680,7 @@ function ReactionSystem(eqs, iv, unknowns, ps;
680680

681681
ReactionSystem(eqs′, rxs, iv′, sivs′, unknowns′, spcs, ps′, var_to_name, observed, name,
682682
systems, defaults, connection_type, nps, combinatoric_ratelaws,
683-
ccallbacks, dcallbacks, metadata, false; checks = checks)
683+
ccallbacks, dcallbacks, metadata; checks = checks)
684684
end
685685

686686
function ReactionSystem(rxs::Vector, iv = Catalyst.DEFAULT_IV; kwargs...)

test/dsl/custom_functions.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ let
138138
end
139139

140140
# Tests `Equation`s.
141+
# Tests using non-default independent variable.
141142
let
142-
@variables X(t) Y(t)
143+
@variables T X(T) Y(T)
143144
@parameters K V N
144145

145146
eq1 = 0 ~ mm(X, V, K)

test/extensions/bifurcation_kit.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ using BifurcationKit, Catalyst, Test
77
using StableRNGs
88
rng = StableRNG(12345)
99

10-
### Run Tests ###
10+
11+
### Basic Tests ###
1112

1213
# Brusselator extended with conserved species.
1314
# Runs full computation, checks values corresponds to known values.
@@ -174,4 +175,20 @@ let
174175

175176
# Checks that there is an error if information for conserved quantities computation is not provided.
176177
@test_throws Exception bprob = BifurcationProblem(rn, u_guess, p_start, k1; plot_var = X1)
178+
end
179+
180+
181+
### Other Tests ###
182+
183+
# Checks that `BifurcationProblem`s cannot be generated from non-complete `ReactionSystems`s.
184+
let
185+
# Create model.
186+
incomplete_network = @network_component begin
187+
(p, d), 0 <--> X
188+
end
189+
u0_guess = [:X => 1.0]
190+
p_start = [p => 1.0, d => 0.2]
191+
192+
# Computes bifurcation diagram.
193+
@test_throws Exception BifurcationProblem(incomplete_network, u0_guess, p_start, :p)
177194
end

test/extensions/homotopy_continuation.jl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import HomotopyContinuation
77
# Fetch test functions.
88
include("../test_functions.jl")
99

10-
### Run Tests ###
10+
### Basic Tests ###
1111

1212
# Tests for network without conservation laws.
1313
# Tests for Symbol parameter input.
@@ -104,4 +104,19 @@ let
104104
end
105105

106106
@test_throws Exception hc_steady_states(rs, [:v => 5.0, :K => 2.5, :n => 2.7, :d => 1.0]; show_progress=false)
107+
end
108+
109+
110+
### Other Tests ###
111+
112+
# Checks that `hc_steady_states` cannot be applied to non-complete `ReactionSystems`s.
113+
let
114+
# Create model.
115+
incomplete_network = @network_component begin
116+
(p, d), 0 <--> X
117+
end
118+
p_start = [p => 1.0, d => 0.2]
119+
120+
# Computes bifurcation diagram.
121+
@test_throws Exception hc_steady_states(incomplete_network, p_start)
107122
end

test/extensions/structural_identifiability.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function sym_dict(dict_in)
1717
end
1818

1919

20-
### Run Tests ###
20+
### Basic Tests ###
2121

2222
# Tests for Goodwin model (model with both global, local, and non identifiable components).
2323
# Tests for system using Catalyst function (in this case, Michaelis-Menten function)
@@ -306,4 +306,21 @@ let
306306
:x3 => :globally,
307307
)
308308
@test length(find_identifiable_functions(rs, measured_quantities = [:x3])) == 1
309+
end
310+
311+
312+
### Other Tests ###
313+
314+
# Checks that identifiability functions cannot be applied to non-complete `ReactionSystems`s.
315+
let
316+
# Create model.
317+
incomplete_network = @network_component begin
318+
(p, d), 0 <--> X
319+
end
320+
measured_quantities = [:X]
321+
322+
# Computes bifurcation diagram.
323+
@test_throws Exception assess_identifiability(incomplete_network; measured_quantities)
324+
@test_throws Exception assess_local_identifiability(incomplete_network; measured_quantities)
325+
@test_throws Exception find_identifiable_functions(incomplete_network; measured_quantities)
309326
end

0 commit comments

Comments
 (0)