Skip to content

Commit b8b5656

Browse files
committed
add reactionsystem struct check function
1 parent 48edfb5 commit b8b5656

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/reactionsystem.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ end
208208
### ReactionSystem Structure ###
209209

210210
# Constant storing all reaction system fields (in order). Used to check whether the `ReactionSystem`
211-
# structure have been updated (in the `reactionsystem_uptodate` function).
211+
# structure have been updated (in the `reactionsystem_uptodate_check` function).
212212
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,
@@ -1036,8 +1036,10 @@ end
10361036
# `reactionsystem_fields` constant. If this is the case, returns `false`. This is used in
10371037
# certain functionalities which would break if the `ReactionSystem` structure is updated without
10381038
# also updating tehse functionalities.
1039-
function reactionsystem_uptodate()
1040-
fieldnames(ReactionSystem) == reactionsystem_fields
1039+
function reactionsystem_uptodate_check()
1040+
if fieldnames(ReactionSystem) != reactionsystem_fields
1041+
@warn "The `ReactionSystem` strcuture have been modified without this being taken into account in the functionality you are attempting to use. Please report this at https://github.com/SciML/Catalyst.jl/issues. Proceed with cautioun, as there might be errors in whichever funcionality you are attempting to use".
1042+
end
10411043
end
10421044

10431045
# used in the `__unpacksys` function.

src/reactionsystem_serialisation/serialise_reactionsystem.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Notes:
3333
- The `ReactionSystem` is saved using *programmatic* (not DSL) format for model creation.
3434
"""
3535
function save_reactionsystem(filename::String, rn::ReactionSystem; annotate = true, safety_check = true)
36+
reactionsystem_uptodate_check()
3637
open(filename, "w") do file
3738
write(file, get_full_system_string(rn, annotate, true))
3839
end

0 commit comments

Comments
 (0)