Skip to content

Commit 552eb62

Browse files
committed
up
1 parent adcc75f commit 552eb62

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/reactionsystem.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ end
207207

208208
### ReactionSystem Structure ###
209209

210+
# Constant storing all reaction system fields (in order). Used to check whether the `ReactionSystem`
211+
# structure have been updated (in the `reactionsystem_uptodate` function).
212+
const reactionsystem_fields = [:eqs, :rxs, :iv, :sivs, :unknowns, :species, :ps, :var_to_name,
213+
:observed, :name, :systems, :defaults, :connection_type,
214+
:networkproperties, :combinatoric_ratelaws, :continuous_events,
215+
:discrete_events, :metadata, :complete]
216+
210217
"""
211218
$(TYPEDEF)
212219
@@ -1025,6 +1032,14 @@ end
10251032

10261033
### General `ReactionSystem`-specific Functions ###
10271034

1035+
# Checks if the `ReactionSystem` structure have been updated without also updating the
1036+
# `reactionsystem_fields` constant. If this is the case, returns `false`. This is used in
1037+
# certain functionalities which would break if the `ReactionSystem` structure is updated without
1038+
# also updating tehse functionalities.
1039+
function reactionsystem_uptodate()
1040+
fieldnames(ReactionSystem) == reactionsystem_fields
1041+
end
1042+
10281043
# used in the `__unpacksys` function.
10291044
function __unpacksys(rn)
10301045
ex = :(begin end)

test/reactionsystem_core/reactionsystem.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,4 +740,12 @@ let
740740
@test nameof(ModelingToolkit.get_iv(empty_network)) == :t
741741
@test length(ModelingToolkit.get_unknowns(empty_network)) == 0
742742
@test length(ModelingToolkit.get_ps(empty_network)) == 0
743+
end
744+
745+
# Checks that the `reactionsystem_uptodate` function work. If it does not, the ReactionSystem
746+
# strcuture's fields have been updated, without updating the `reactionsystem_fields` costant. If so,
747+
# there are several places in the code where the `reactionsystem_uptodate` function is called, here
748+
# the code might need adaptation to take the updated reaction system into account.
749+
let
750+
@test Catalyst.reactionsystem_uptodate()
743751
end

0 commit comments

Comments
 (0)