Skip to content

Commit 48edfb5

Browse files
committed
save_reaction_network -> save_reactionsystem
1 parent 241cbd5 commit 48edfb5

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

src/Catalyst.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,6 @@ include("spatial_reaction_systems/lattice_jump_systems.jl")
188188
include("reactionsystem_serialisation/serialisation_support.jl")
189189
include("reactionsystem_serialisation/serialise_fields.jl")
190190
include("reactionsystem_serialisation/serialise_reactionsystem.jl")
191-
export save_reaction_network
191+
export save_reactionsystem
192192

193193
end # module

src/reactionsystem.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ end
209209

210210
# Constant storing all reaction system fields (in order). Used to check whether the `ReactionSystem`
211211
# structure have been updated (in the `reactionsystem_uptodate` function).
212-
const reactionsystem_fields = [:eqs, :rxs, :iv, :sivs, :unknowns, :species, :ps, :var_to_name,
212+
const reactionsystem_fields = (:eqs, :rxs, :iv, :sivs, :unknowns, :species, :ps, :var_to_name,
213213
:observed, :name, :systems, :defaults, :connection_type,
214214
:networkproperties, :combinatoric_ratelaws, :continuous_events,
215-
:discrete_events, :metadata, :complete]
215+
:discrete_events, :metadata, :complete)
216216

217217
"""
218218
$(TYPEDEF)

src/reactionsystem_serialisation/serialise_reactionsystem.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
save_reaction_network(filename::String, rn::ReactionSystem; annotate = true, safety_check = true)
2+
save_reactionsystem(filename::String, rn::ReactionSystem; annotate = true, safety_check = true)
33
44
Save a `ReactionSystem` model to a file. The `ReactionSystem` is saved as runnable Julia code. This
55
can both be used to save a `ReactionSystem` model, but also to write it to a file for easy inspection.
@@ -18,7 +18,7 @@ Example:
1818
rn = @reaction_network begin
1919
(p,d), 0 <--> X
2020
end
21-
save_reaction_network("rn.jls", rn)
21+
save_reactionsystem("rn.jls", rn)
2222
```
2323
The model can now be loaded using
2424
```julia
@@ -32,14 +32,14 @@ Notes:
3232
- Reaction systems with components that have units cannot currently be saved.
3333
- The `ReactionSystem` is saved using *programmatic* (not DSL) format for model creation.
3434
"""
35-
function save_reaction_network(filename::String, rn::ReactionSystem; annotate = true, safety_check = true)
35+
function save_reactionsystem(filename::String, rn::ReactionSystem; annotate = true, safety_check = true)
3636
open(filename, "w") do file
3737
write(file, get_full_system_string(rn, annotate, true))
3838
end
3939
if safety_check
4040
if !isequal(rn, include(joinpath(pwd(), filename)))
4141
rm(filename)
42-
error("The serialised `ReactionSystem` is not equal to the original one. Please make a report (including the full system) at https://github.com/SciML/Catalyst.jl/issues. To disable this behaviour, please pass the `safety_check = false` argument to `save_reaction_network` (warning, this will permit the serialisation of an erroneous system).")
42+
error("The serialised `ReactionSystem` is not equal to the original one. Please make a report (including the full system) at https://github.com/SciML/Catalyst.jl/issues. To disable this behaviour, please pass the `safety_check = false` argument to `save_reactionsystem` (warning, this will permit the serialisation of an erroneous system).")
4343
end
4444
end
4545
return nothing

test/miscellaneous_tests/reactionsystem_serialisation.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ let
2626
@equations D(V) ~ 1 - V
2727
d, X --> 0
2828
end
29-
save_reaction_network("test_serialisation_annotated.jl", rn; safety_check = false)
30-
save_reaction_network("test_serialisation.jl", rn; annotate = false, safety_check = false)
29+
save_reactionsystem("test_serialisation_annotated.jl", rn; safety_check = false)
30+
save_reactionsystem("test_serialisation.jl", rn; annotate = false, safety_check = false)
3131

3232
# Checks equivalence.
3333
file_string_annotated = read("test_serialisation_annotated.jl", String)
@@ -159,7 +159,7 @@ let
159159
rs = complete(rs1)
160160

161161
# Loads the model and checks that it is correct. Removes the saved file
162-
save_reaction_network("serialised_rs.jl", rs; safety_check = false)
162+
save_reactionsystem("serialised_rs.jl", rs; safety_check = false)
163163
rs_loaded = include("../serialised_rs.jl")
164164
@test rs == rs_loaded
165165
rm("serialised_rs.jl")
@@ -247,7 +247,7 @@ let
247247

248248
# Creates model and checks it against serialised version.
249249
@named rs = ReactionSystem([], τ, [X, Y, Z, U, V, W, A, B, C, D, E, F, G], [a, b, c, d, e, f])
250-
save_reaction_network("serialised_rs.jl", rs; safety_check = false)
250+
save_reactionsystem("serialised_rs.jl", rs; safety_check = false)
251251
@test rs == include("../serialised_rs.jl")
252252
rm("serialised_rs.jl")
253253
end
@@ -348,9 +348,9 @@ let
348348
rs = complete(rs_1)
349349

350350
# Checks that the correct system is saved (both complete and incomplete ones).
351-
save_reaction_network("serialised_rs_incomplete.jl", rs_1; safety_check = false)
351+
save_reactionsystem("serialised_rs_incomplete.jl", rs_1; safety_check = false)
352352
@test isequal(rs_1, include("../serialised_rs_incomplete.jl"))
353-
save_reaction_network("serialised_rs_complete.jl", rs; safety_check = false)
353+
save_reactionsystem("serialised_rs_complete.jl", rs; safety_check = false)
354354
@test isequal(rs, include("../serialised_rs_complete.jl"))
355355
rm("serialised_rs_incomplete.jl")
356356
rm("serialised_rs_complete.jl")
@@ -379,7 +379,7 @@ let
379379
end
380380

381381
# Checks that serialisation works.
382-
save_reaction_network("serialised_rs.jl", rs; safety_check = false)
382+
save_reactionsystem("serialised_rs.jl", rs; safety_check = false)
383383
@test_broken isequal(rs, include("../serialised_rs.jl"))
384384
rm("serialised_rs.jl")
385385
end
@@ -400,7 +400,7 @@ let
400400

401401
@named osys = ODESystem([eq], t)
402402
@named rs = ReactionSystem(rxs, t; systems = [osys])
403-
@test_throws Exception save_reaction_network("failed_serialisation.jl", rs)
403+
@test_throws Exception save_reactionsystem("failed_serialisation.jl", rs)
404404
end
405405

406406
# Checks that completeness is recorded correctly.
@@ -410,7 +410,7 @@ let
410410
rs_complete = @reaction_network begin
411411
(p,d), 0 <--> X
412412
end
413-
save_reaction_network("serialised_rs_complete.jl", rs_complete)
413+
save_reactionsystem("serialised_rs_complete.jl", rs_complete)
414414
rs_complete_loaded = include("../serialised_rs_complete.jl")
415415
@test ModelingToolkit.iscomplete(rs_complete_loaded)
416416
rm("serialised_rs_complete.jl")
@@ -419,7 +419,7 @@ let
419419
rs_incomplete = @network_component begin
420420
(p,d), 0 <--> X
421421
end
422-
save_reaction_network("serialised_rs_incomplete.jl", rs_incomplete)
422+
save_reactionsystem("serialised_rs_incomplete.jl", rs_incomplete)
423423
rs_incomplete_loaded = include("../serialised_rs_incomplete.jl")
424424
@test !ModelingToolkit.iscomplete(rs_incomplete_loaded)
425425
rm("serialised_rs_incomplete.jl")

0 commit comments

Comments
 (0)