Skip to content

Commit d60cb78

Browse files
committed
round 2
1 parent db75226 commit d60cb78

17 files changed

+64
-63
lines changed

ext/CatalystBifurcationKitExtension/bifurcation_kit_extension.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ function BK.BifurcationProblem(rs::ReactionSystem, u0_bif, ps, bif_par, args...;
2626
nsys = complete(nsys)
2727

2828
# Makes BifurcationProblem (this call goes through the ModelingToolkit-based BifurcationKit extension).
29-
return BK.BifurcationProblem(nsys, u0_bif, ps, bif_par, args...; plot_var,
29+
return BK.BifurcationProblem(nsys, u0_bif, ps, bif_par, args...; plot_var,
3030
record_from_solution, jac, kwargs...)
3131
end

ext/CatalystHomotopyContinuationExtension/homotopy_continuation_extension.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function steady_state_polynomial(rs::ReactionSystem, ps, u0)
5252
ns = complete(convert(NonlinearSystem, rs; remove_conserved = true))
5353
pre_varmap = [symmap_to_varmap(rs, u0)..., symmap_to_varmap(rs, ps)...]
5454
Catalyst.conservationlaw_errorcheck(rs, pre_varmap)
55-
p_vals = ModelingToolkit.varmap_to_vars(pre_varmap, parameters(ns);
55+
p_vals = ModelingToolkit.varmap_to_vars(pre_varmap, parameters(ns);
5656
defaults = ModelingToolkit.defaults(ns))
5757
p_dict = Dict(parameters(ns) .=> p_vals)
5858
eqs_pars_funcs = vcat(equations(ns), conservedequations(rs))

ext/CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ function Catalyst.make_si_ode(rs::ReactionSystem; measured_quantities = [], know
3131
# Creates a MTK ODESystem, and a list of measured quantities (there are equations).
3232
# Gives these to SI to create an SI ode model of its preferred form.
3333
osys, conseqs, _ = make_osys(rs; remove_conserved)
34-
measured_quantities = make_measured_quantities( rs, measured_quantities, known_p, conseqs;
35-
ignore_no_measured_warn)
34+
measured_quantities = make_measured_quantities(rs, measured_quantities, known_p,
35+
conseqs; ignore_no_measured_warn)
3636
return SI.mtk_to_si(osys, measured_quantities)[1]
3737
end
3838

@@ -64,16 +64,16 @@ Notes:
6464
- `measured_quantities` and `known_p` input may also be symbolic (e.g. measured_quantities = [rs.X])
6565
"""
6666
function SI.assess_local_identifiability(rs::ReactionSystem, args...;
67-
measured_quantities = [], known_p = [], funcs_to_check = Vector(),
67+
measured_quantities = [], known_p = [], funcs_to_check = Vector(),
6868
remove_conserved = true, ignore_no_measured_warn = false, kwargs...)
6969
# Creates a ODESystem, list of measured quantities, and functions to check, of SI's preferred form.
7070
osys, conseqs, vars = make_osys(rs; remove_conserved)
71-
measured_quantities = make_measured_quantities( rs, measured_quantities, known_p, conseqs;
72-
ignore_no_measured_warn)
71+
measured_quantities = make_measured_quantities(rs, measured_quantities, known_p,
72+
conseqs; ignore_no_measured_warn)
7373
funcs_to_check = make_ftc(funcs_to_check, conseqs, vars)
7474

7575
# Computes identifiability and converts it to a easy to read form.
76-
out = SI.assess_local_identifiability( sys, args...; measured_quantities,
76+
out = SI.assess_local_identifiability(sys, args...; measured_quantities,
7777
funcs_to_check, kwargs...)
7878
return make_output(out, funcs_to_check, reverse.(conseqs))
7979
end
@@ -103,13 +103,13 @@ Notes:
103103
- This function is part of the StructuralIdentifiability.jl extension. StructuralIdentifiability.jl must be imported to access it.
104104
- `measured_quantities` and `known_p` input may also be symbolic (e.g. measured_quantities = [rs.X])
105105
"""
106-
function SI.assess_identifiability( rs::ReactionSystem, args...;
107-
measured_quantities = [], known_p = [], funcs_to_check = Vector(),
106+
function SI.assess_identifiability(rs::ReactionSystem, args...;
107+
measured_quantities = [], known_p = [], funcs_to_check = Vector(),
108108
remove_conserved = true, ignore_no_measured_warn = false, kwargs...)
109109
# Creates a ODESystem, list of measured quantities, and functions to check, of SI's preferred form.
110110
osys, conseqs, vars = make_osys(rs; remove_conserved)
111-
measured_quantities = make_measured_quantities(rs, measured_quantities, known_p, conseqs;
112-
ignore_no_measured_warn)
111+
measured_quantities = make_measured_quantities(rs, measured_quantities, known_p,
112+
conseqs; ignore_no_measured_warn)
113113
funcs_to_check = make_ftc(funcs_to_check, conseqs, vars)
114114

115115
# Computes identifiability and converts it to a easy to read form.
@@ -143,13 +143,13 @@ Notes:
143143
- This function is part of the StructuralIdentifiability.jl extension. StructuralIdentifiability.jl must be imported to access it.
144144
- `measured_quantities` and `known_p` input may also be symbolic (e.g. measured_quantities = [rs.X])
145145
"""
146-
function SI.find_identifiable_functions(rs::ReactionSystem, args...;
147-
measured_quantities = [], known_p = [], remove_conserved = true,
146+
function SI.find_identifiable_functions(rs::ReactionSystem, args...;
147+
measured_quantities = [], known_p = [], remove_conserved = true,
148148
ignore_no_measured_warn = false, kwargs...)
149149
# Creates a ODESystem, and list of measured quantities, of SI's preferred form.
150150
osys, conseqs = make_osys(rs; remove_conserved)
151-
measured_quantities = make_measured_quantities(
152-
rs, measured_quantities, known_p, conseqs; ignore_no_measured_warn)
151+
measured_quantities = make_measured_quantities(rs, measured_quantities, known_p,
152+
conseqs; ignore_no_measured_warn)
153153

154154
# Computes identifiable functions and converts it to a easy to read form.
155155
out = SI.find_identifiable_functions(osys, args...; measured_quantities, kwargs...)

src/chemistry_functionality.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function make_compound(expr)
8585
# Loops through all components, add the component and the coefficients to the corresponding vectors
8686
# Cannot extract directly using e.g. "getfield.(composition, :reactant)" because then
8787
# we get something like :([:C, :O]), rather than :([C, O]).
88-
composition = Catalyst.recursive_find_reactants!( xpr.args[3], 1,
88+
composition = Catalyst.recursive_find_reactants!(xpr.args[3], 1,
8989
Vector{ReactantStruct}(undef, 0))
9090
components = :([]) # Becomes something like :([C, O]).
9191
coefficients = :([]) # Becomes something like :([1, 2]).
@@ -122,12 +122,12 @@ function make_compound(expr)
122122
species_declaration_expr = Expr(:escape, :(@species $species_expr))
123123
multiple_ivs_error_check_expr = Expr(:escape,
124124
:($(isempty(ivs)) && (length($ivs_get_expr) > 1) &&
125-
error($COMPOUND_CREATION_ERROR_DEPENDENT_VAR_REQUIRED)))
125+
error($COMPOUND_CREATION_ERROR_DEPENDENT_VAR_REQUIRED)))
126126
iv_designation_expr = Expr(:escape,
127127
:($(isempty(ivs)) && ($species_name = $(species_name)($(ivs_get_expr)...))))
128128
iv_check_expr = Expr(:escape,
129129
:(issetequal(arguments(ModelingToolkit.unwrap($species_name)), $ivs_get_expr) ||
130-
error("The independent variable(S) provided to the compound ($(arguments(ModelingToolkit.unwrap($species_name)))), and those of its components ($($ivs_get_expr)))), are not identical.")))
130+
error("The independent variable(S) provided to the compound ($(arguments(ModelingToolkit.unwrap($species_name)))), and those of its components ($($ivs_get_expr)))), are not identical.")))
131131
compound_designation_expr = Expr(:escape,
132132
:($species_name = ModelingToolkit.setmetadata(
133133
$species_name, Catalyst.CompoundSpecies, true)))
@@ -197,7 +197,7 @@ function make_compounds(expr)
197197

198198
# The output needs to be converted to Vector{Num} (from Vector{SymbolicUtils.BasicSymbolic{Real}}) to be consistent with e.g. @variables.
199199
compound_declarations.args[end] = :([ModelingToolkit.wrap(cmp)
200-
for cmp in $(compound_declarations.args[end])])
200+
for cmp in $(compound_declarations.args[end])])
201201

202202
# Returns output that.
203203
return compound_declarations
@@ -264,7 +264,7 @@ function balance_reaction(reaction::Reaction)
264264
prodstoich = stoich[(length(reaction.substrates) + 1):end]
265265

266266
# Create a new reaction with the balanced stoichiometries
267-
balancedrx = Reaction(reaction.rate, reaction.substrates, reaction.products,
267+
balancedrx = Reaction(reaction.rate, reaction.substrates, reaction.products,
268268
substoich, prodstoich)
269269

270270
# Add the reaction to the vector of all reactions

src/dsl.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ function get_reactions(exprs::Vector{Expr}, reactions = Vector{ReactionStruct}(u
417417
push_reactions!(reactions, reaction.args[3], reaction.args[2],
418418
rate.args[2], metadata.args[2], arrow)
419419
elseif in(arrow, fwd_arrows)
420-
push_reactions!( reactions, reaction.args[2], reaction.args[3],
420+
push_reactions!(reactions, reaction.args[2], reaction.args[3],
421421
rate, metadata, arrow)
422422
elseif in(arrow, bwd_arrows)
423423
push_reactions!(reactions, reaction.args[3], reaction.args[2],
@@ -476,7 +476,7 @@ function push_reactions!(reactions::Vector{ReactionStruct}, sub_line::ExprValues
476476
error("Some reaction metadata fields where repeated: $(metadata_entries)")
477477
end
478478

479-
push!(reactions, ReactionStruct(get_tup_arg(sub_line, i),
479+
push!(reactions,ReactionStruct(get_tup_arg(sub_line, i),
480480
get_tup_arg(prod_line, i), get_tup_arg(rate, i), metadata_i))
481481
end
482482
end
@@ -640,11 +640,11 @@ function read_events_option(options, event_type::Symbol)
640640
# Formatting error checks.
641641
# NOTE: Maybe we should move these deeper into the system (rather than the DSL), throwing errors more generally?
642642
if (arg isa Expr) && (arg.head != :call) || (arg.args[1] != :(=>)) ||
643-
(length(arg.args) != 3)
643+
(length(arg.args) != 3)
644644
error("Events should be on form `condition => affect`, separated by a `=>`. This appears not to be the case for: $(arg).")
645645
end
646646
if (arg isa Expr) && (arg.args[2] isa Expr) && (arg.args[2].head != :vect) &&
647-
(event_type == :continuous_events)
647+
(event_type == :continuous_events)
648648
error("The condition part of continious events (the left-hand side) must be a vector. This is not the case for: $(arg).")
649649
end
650650
if (arg isa Expr) && (arg.args[3] isa Expr) && (arg.args[3].head != :vect)
@@ -668,7 +668,7 @@ function read_equations_options(options, variables_declared)
668668
eqs_input = haskey(options, :equations) ? options[:equations].args[3] : :(begin end)
669669
eqs_input = option_block_form(eqs_input)
670670
equations = Expr[]
671-
ModelingToolkit.parse_equations!(Expr(:block), equations,
671+
ModelingToolkit.parse_equations!(Expr(:block), equations,
672672
Dict{Symbol, Any}(), eqs_input)
673673

674674
# Loops through all equations, checks for lhs of the form `D(X) ~ ...`.
@@ -687,7 +687,7 @@ function read_equations_options(options, variables_declared)
687687
lhs = eq.args[2]
688688
# if lhs: is an expression. Is a function call. The function's name is D. Calls a single symbol.
689689
if (lhs isa Expr) && (lhs.head == :call) && (lhs.args[1] == :D) &&
690-
(lhs.args[2] isa Symbol)
690+
(lhs.args[2] isa Symbol)
691691
diff_var = lhs.args[2]
692692
if in(diff_var, forbidden_symbols_error)
693693
error("A forbidden symbol ($(diff_var)) was used as an variable in this differential equation: $eq")
@@ -755,7 +755,7 @@ function read_observed_options(options, species_n_vars_declared, ivs_sorted)
755755
error("An interpoalted observable have been used, which has also been explicitly delcared within the system using eitehr @species or @variables. This is not permited.")
756756
end
757757
if ((obs_name in species_n_vars_declared) || is_escaped_expr(obs_eq.args[2])) &&
758-
!isnothing(metadata)
758+
!isnothing(metadata)
759759
error("Metadata was provided to observable $obs_name in the `@observables` macro. However, the obervable was also declared separately (using either @species or @variables). When this is done, metadata should instead be provided within the original @species or @variable declaration.")
760760
end
761761

@@ -771,7 +771,7 @@ function read_observed_options(options, species_n_vars_declared, ivs_sorted)
771771
# Adds a line to the `observed_vars` expression, setting the ivs for this observable.
772772
# Cannot extract directly using e.g. "getfield.(dependants_structs, :reactant)" because
773773
# then we get something like :([:X1, :X2]), rather than :([X1, X2]).
774-
dep_var_expr = :(filter(!MT.isparameter,
774+
dep_var_expr = :(filter(!MT.isparameter,
775775
Symbolics.get_variables($(obs_eq.args[3]))))
776776
ivs_get_expr = :(unique(reduce(vcat, [arguments(MT.unwrap(dep))
777777
for dep in $dep_var_expr])))

src/expression_utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function find_varinfo_in_declaration(expr)
8282
# Case: X(t) = 1.0
8383
(expr.args[1].head == :call) &&
8484
(return expr.args[1].args[1], expr.args[1].args[2:end], expr.args[2].args[1],
85-
nothing)
85+
nothing)
8686
end
8787
if expr.head == :tuple
8888
# Case: X, [metadata=true]

src/reactionsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ end
463463
# While species are ordered before variables in the unknowns vector, this ordering is not imposed here,
464464
# but carried out at a later stage.
465465
function make_ReactionSystem_internal(rxs_and_eqs::Vector, iv, us_in, ps_in;
466-
spatial_ivs = nothing, continuous_events = [], discrete_events = [],
466+
spatial_ivs = nothing, continuous_events = [], discrete_events = [],
467467
observed = [], kwargs...)
468468

469469
# Filters away any potential obervables from `states` and `spcs`.

src/reactionsystem_conversions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ function Base.convert(::Type{<:SDESystem}, rs::ReactionSystem;
607607
ists, ispcs = get_indep_sts(flatrs, remove_conserved)
608608
eqs = assemble_drift(flatrs, ispcs; combinatoric_ratelaws, include_zero_odes,
609609
remove_conserved)
610-
noiseeqs = assemble_diffusion(flatrs, ists, ispcs;
610+
noiseeqs = assemble_diffusion(flatrs, ists, ispcs;
611611
combinatoric_ratelaws, remove_conserved)
612612
eqs, us, ps, obs, defs = addconstraints!(eqs, flatrs, ists, ispcs; remove_conserved)
613613

src/reactionsystem_serialisation/serialisation_support.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ end
6969

7070
# Converts a numeric expression (e.g. p*X + 2Y) to a string (e.g. "p*X + 2Y"). Also ensures that for
7171
# any variables (e.g. X(t)) the call part is stripped, and only variable name (e.g. X) is written.
72-
function expression_2_string(expr;
72+
function expression_2_string(expr;
7373
strip_call_dict = make_strip_call_dict(Symbolics.get_variables(expr)))
7474
strip_called_expr = substitute(expr, strip_call_dict)
7575
return repr(strip_called_expr)
@@ -89,7 +89,7 @@ function syms_2_declaration_string(syms; multiline_format = false)
8989
decs_string = (multiline_format ? " begin" : "")
9090
for sym in syms
9191
delimiter = (multiline_format ? "\n\t" : " ")
92-
@string_append! decs_string delimiter sym_2_declaration_string(sym;
92+
@string_append! decs_string delimiter sym_2_declaration_string(sym;
9393
multiline_format)
9494
end
9595
multiline_format && (@string_append! decs_string "\nend")
@@ -109,7 +109,7 @@ function sym_2_declaration_string(sym; multiline_format = false)
109109
if !(sym isa SymbolicUtils.BasicSymbolic{Real})
110110
sym_type = String(Symbol(typeof(Symbolics.unwrap(sym))))
111111
if (get_substring(sym_type, 1, 28) != "SymbolicUtils.BasicSymbolic{") ||
112-
(get_char_end(sym_type, 0) != '}')
112+
(get_char_end(sym_type, 0) != '}')
113113
error("Encountered symbolic of unexpected type: $sym_type.")
114114
end
115115
@string_append! dec_string "::" get_substring_end(sym_type, 29, -1)

src/reactionsystem_serialisation/serialise_fields.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ SIVS_FS = (has_sivs, get_sivs_string, get_sivs_annotation)
4343

4444
# Function which handles the addition of species, variable, and parameter declarations to the file
4545
# text. These must be handled as a unity in case there are default value dependencies between these.
46-
function handle_us_n_ps(file_text::String, rn::ReactionSystem,
46+
function handle_us_n_ps(file_text::String, rn::ReactionSystem,
4747
annotate::Bool, top_level::Bool)
4848
# Fetches the systems parameters, species, and variables. Computes the `has_` `Bool`s.
4949
ps_all = get_ps(rn)
@@ -102,11 +102,11 @@ function handle_us_n_ps(file_text::String, rn::ReactionSystem,
102102
while !(isempty(remaining_ps) && isempty(remaining_sps) && isempty(remaining_vars))
103103
# Checks which parameters/species/variables can be written. The `dependency_split`
104104
# function updates the `remaining_` input.
105-
writable_ps = dependency_split!(remaining_ps,
105+
writable_ps = dependency_split!(remaining_ps,
106106
[remaining_ps; remaining_sps; remaining_vars])
107-
writable_sps = dependency_split!(remaining_sps,
107+
writable_sps = dependency_split!(remaining_sps,
108108
[remaining_ps; remaining_sps; remaining_vars])
109-
writable_vars = dependency_split!(remaining_vars,
109+
writable_vars = dependency_split!(remaining_vars,
110110
[remaining_ps; remaining_sps; remaining_vars])
111111

112112
# Writes those that can be written.
@@ -409,7 +409,7 @@ function get_continuous_events_annotation(rn::ReactionSystem)
409409
end
410410

411411
# Combines the 3 -related functions in a constant tuple.
412-
CONTINUOUS_EVENTS_FS = (has_continuous_events, get_continuous_events_string,
412+
CONTINUOUS_EVENTS_FS = (has_continuous_events, get_continuous_events_string,
413413
get_continuous_events_annotation)
414414

415415
### Handles Discrete Events ###
@@ -466,15 +466,15 @@ function get_discrete_events_annotation(rn::ReactionSystem)
466466
end
467467

468468
# Combines the 3 -related functions in a constant tuple.
469-
DISCRETE_EVENTS_FS = (has_discrete_events, get_discrete_events_string,
469+
DISCRETE_EVENTS_FS = (has_discrete_events, get_discrete_events_string,
470470
get_discrete_events_annotation)
471471

472472
### Handles Systems ###
473473

474474
# Specific `push_field` function, which is used for the system field (where the annotation option
475475
# must be passed to the `get_component_string` function). Since non-ReactionSystem systems cannot be
476476
# written to file, this functions throws an error if any such systems are encountered.
477-
function push_systems_field(file_text::String, rn::ReactionSystem,
477+
function push_systems_field(file_text::String, rn::ReactionSystem,
478478
annotate::Bool, top_level::Bool)
479479
# Checks whther there are any subsystems, and if these are ReactionSystems.
480480
has_systems(rn) || (return (file_text, false))
@@ -542,5 +542,5 @@ function get_connection_type_annotation(rn::ReactionSystem)
542542
end
543543

544544
# Combines the 3 connection types-related functions in a constant tuple.
545-
CONNECTION_TYPE_FS = (has_connection_type, get_connection_type_string,
545+
CONNECTION_TYPE_FS = (has_connection_type, get_connection_type_string,
546546
get_connection_type_annotation)

0 commit comments

Comments
 (0)