Skip to content

Commit 0787d78

Browse files
committed
remove debug, update docstring, update comments, create function tuple.
1 parent 9c1607d commit 0787d78

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/registered_functions.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,19 @@ function Symbolics.derivative(::typeof(hillar), args::NTuple{5, Any}, ::Val{5})
109109
(args[1]^args[5] + args[2]^args[5] + args[4]^args[5])^2
110110
end
111111

112+
# Tuple storing all registered function (for use in various functionalities).
113+
const registered_funcs = (mm, mmr, hill, hillr, hillar)
114+
112115
### Custom CRN FUnction-related Functions ###
113116

114117
"""
115-
expand_registered_functions(expr)
118+
expand_registered_functions(in)
116119
117-
Takes an expression, and expands registered function expressions. E.g. `mm(X,v,K)` is replaced with v*X/(X+K). Currently supported functions: `mm`, `mmr`, `hill`, `hillr`, and `hill`.
120+
Takes an expression, and expands registered function expressions. E.g. `mm(X,v,K)` is replaced
121+
with v*X/(X+K). Currently supported functions: `mm`, `mmr`, `hill`, `hillr`, and `hill`. Can
122+
be applied to a reaction system, a reaction, an equation, or a symbolic expression. The input
123+
is not modified, while an output with any functions expanded is returned. If applied to a
124+
reaction system model, any cached network properties are reset.
118125
"""
119126
function expand_registered_functions(expr)
120127
if hasnode(is_catalyst_function, expr)
@@ -126,8 +133,7 @@ end
126133
# Checks whether an expression corresponds to a catalyst function call (e.g. `mm(X,v,K)`).
127134
function is_catalyst_function(expr)
128135
iscall(expr) || (return false)
129-
return operation(expr) in [
130-
Catalyst.mm, Catalyst.mmr, Catalyst.hill, Catalyst.hillr, Catalyst.hillar]
136+
return operation(expr) in registered_funcs
131137
end
132138

133139
# If the input expression corresponds to a catalyst function call (e.g. `mm(X,v,K)`), returns
@@ -155,7 +161,7 @@ function expand_registered_functions(rx::Reaction)
155161
rx.substoich, rx.prodstoich, rx.netstoich, rx.only_use_rate, rx.metadata)
156162
end
157163

158-
# If applied to a Equation, returns it with it applied to lhs and rhs
164+
# If applied to a Equation, returns it with it applied to lhs and rhs.
159165
function expand_registered_functions(eq::Equation)
160166
return expand_registered_functions(eq.lhs) ~ expand_registered_functions(eq.rhs)
161167
end
@@ -174,7 +180,7 @@ function expand_registered_functions(de::ModelingToolkit.SymbolicDiscreteCallbac
174180
return ModelingToolkit.SymbolicDiscreteCallback(condition, affects)
175181
end
176182

177-
# If applied to a vector, applies it to every element in the vector
183+
# If applied to a vector, applies it to every element in the vector.
178184
function expand_registered_functions(vec::Vector)
179185
return [Catalyst.expand_registered_functions(element) for element in vec]
180186
end
@@ -183,10 +189,6 @@ end
183189
# Currently, `ModelingToolkit.has_X_events` returns `true` even if event vector is empty (hence
184190
# this function cannot be used).
185191
function expand_registered_functions(rs::ReactionSystem)
186-
if isdefined(Main, :Infiltrator)
187-
Main.infiltrate(@__MODULE__, Base.@locals, @__FILE__, @__LINE__)
188-
end
189-
190192
@set! rs.eqs = Catalyst.expand_registered_functions(get_eqs(rs))
191193
@set! rs.rxs = Catalyst.expand_registered_functions(get_rxs(rs))
192194
if !isempty(ModelingToolkit.get_continuous_events(rs))

0 commit comments

Comments
 (0)