@@ -169,14 +169,20 @@ function make_empty_network(; iv=Variable(:t))
169
169
end
170
170
171
171
"""
172
- addspecies!(network::ReactionSystem, s::Variable)
172
+ addspecies!(network::ReactionSystem, s::Variable; disablechecks=false )
173
173
174
- Given a [`ReactionSystem`](@ref), add the species corresponding to the
175
- variable `s` to the network (if it is not already defined). Returns the
176
- integer id of the species within the system.
174
+ Given a [`ReactionSystem`](@ref), add the species corresponding to the variable
175
+ `s` to the network (if it is not already defined). Returns the integer id of the
176
+ species within the system.
177
+
178
+ Notes:
179
+ - `disablechecks` will disable checking for whether the passed in variable is
180
+ already defined, which is useful when adding many new variables to the system.
181
+ *Do not disable checks* unless you are sure the passed in variable is a new
182
+ variable, as this will potentially leave the system in an undefined state.
177
183
"""
178
- function addspecies! (network:: ReactionSystem , s:: Variable )
179
- curidx = findfirst (S -> isequal (S, s), species (network))
184
+ function addspecies! (network:: ReactionSystem , s:: Variable ; disablechecks = false )
185
+ curidx = disablechecks ? nothing : findfirst (S -> isequal (S, s), species (network))
180
186
if curidx === nothing
181
187
push! (network. states, s)
182
188
return length (species (network))
@@ -186,26 +192,36 @@ function addspecies!(network::ReactionSystem, s::Variable)
186
192
end
187
193
188
194
"""
189
- addspecies!(network::ReactionSystem, s::Operation)
195
+ addspecies!(network::ReactionSystem, s::Operation; disablechecks=false )
190
196
191
197
Given a [`ReactionSystem`](@ref), add the species corresponding to the
192
198
variable `s` to the network (if it is not already defined). Returns the
193
199
integer id of the species within the system.
200
+
201
+ - `disablechecks` will disable checking for whether the passed in variable is
202
+ already defined, which is useful when adding many new variables to the system.
203
+ *Do not disable checks* unless you are sure the passed in variable is a new
204
+ variable, as this will potentially leave the system in an undefined state.
194
205
"""
195
- function addspecies! (network:: ReactionSystem , s:: Operation )
206
+ function addspecies! (network:: ReactionSystem , s:: Operation ; disablechecks = false )
196
207
! (s. op isa Variable) && error (" If the passed in species is an Operation, it must correspond to an underlying Variable." )
197
- addspecies! (network, convert (Variable,s))
208
+ addspecies! (network, convert (Variable,s); disablechecks = disablechecks )
198
209
end
199
210
200
211
"""
201
- addparam!(network::ReactionSystem, p::Variable)
212
+ addparam!(network::ReactionSystem, p::Variable; disablechecks=false )
202
213
203
214
Given a [`ReactionSystem`](@ref), add the parameter corresponding to the
204
- variable `p` to the network (if it is not already defined). Returns the
205
- integer id of the parameter within the system.
215
+ variable `p` to the network (if it is not already defined). Returns the integer
216
+ id of the parameter within the system.
217
+
218
+ - `disablechecks` will disable checking for whether the passed in variable is
219
+ already defined, which is useful when adding many new variables to the system.
220
+ *Do not disable checks* unless you are sure the passed in variable is a new
221
+ variable, as this will potentially leave the system in an undefined state.
206
222
"""
207
- function addparam! (network:: ReactionSystem , p:: Variable )
208
- curidx = findfirst (S -> isequal (S, p), params (network))
223
+ function addparam! (network:: ReactionSystem , p:: Variable ; disablechecks = false )
224
+ curidx = disablechecks ? nothing : findfirst (S -> isequal (S, p), params (network))
209
225
if curidx === nothing
210
226
push! (network. ps, p)
211
227
return length (params (network))
@@ -215,15 +231,20 @@ function addparam!(network::ReactionSystem, p::Variable)
215
231
end
216
232
217
233
"""
218
- addparam!(network::ReactionSystem, p::Operation)
234
+ addparam!(network::ReactionSystem, p::Operation; disablechecks=false )
219
235
220
236
Given a [`ReactionSystem`](@ref), add the parameter corresponding to the
221
237
variable `p` to the network (if it is not already defined). Returns the
222
238
integer id of the parameter within the system.
239
+
240
+ - `disablechecks` will disable checking for whether the passed in variable is
241
+ already defined, which is useful when adding many new variables to the system.
242
+ *Do not disable checks* unless you are sure the passed in variable is a new
243
+ variable, as this will potentially leave the system in an undefined state.
223
244
"""
224
- function addparam! (network:: ReactionSystem , p:: Operation )
245
+ function addparam! (network:: ReactionSystem , p:: Operation ; disablechecks = false )
225
246
! (p. op isa Variable) && error (" If the passed in parameter is an Operation, it must correspond to an underlying Variable." )
226
- addparam! (network, convert (Variable,p))
247
+ addparam! (network, convert (Variable,p); disablechecks = disablechecks )
227
248
end
228
249
229
250
"""
0 commit comments