Skip to content

Commit

Permalink
add warning to misc
Browse files Browse the repository at this point in the history
  • Loading branch information
TorkelE committed May 20, 2024
1 parent cdd284f commit bc6c59d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/reaction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,17 @@ Example:
reaction = @reaction k, 0 --> X, [misc="A reaction"]
get_misc(reaction)
```
Notes:
- The `misc` field can contain any valid Julia structure. This mean that Catalyst cannot check it
for symbolci variables that are added here. This means that symbolic variables (e.g. parameters of
species) that are stored here are not accessible to Catalyst. This can cause troubles when e.g.
creating a `ReactionSystem` programmatically (in which case any symbolic variables stored in the
`misc` metadata field should also be explicitly provided to the `ReactionSystem` constructor).
"""
function get_misc(reaction::Reaction)
if has_description(reaction)
if has_misc(reaction)
return getmetadata(reaction, :misc)
else
error("Attempts to access `misc` metadata field for a reaction which does not have a value assigned for this metadata.")
Expand Down
2 changes: 1 addition & 1 deletion test/reactionsystem_core/reaction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ let
@test !Catalyst.has_misc(r1)
@test Catalyst.has_misc(r2)
@test_throws Exception Catalyst.get_misc(r1)
@test isequal(Catalyst.get_misc(r2), ('C', :C))
@test isequal(Catalyst.get_misc(r2), ('M', :M))
end

0 comments on commit bc6c59d

Please sign in to comment.