Skip to content

Commit 283215b

Browse files
committed
up
1 parent 20cbabe commit 283215b

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/reactionsystem_serialisation/serialisation_support.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ end
1414
# E.g `@string_prepend! str1 str_base` becomes `str_base = str1 * str_base`.
1515
macro string_prepend!(input, string)
1616
rhs = :($input * $string)
17-
esc(:($string = $rhs))
17+
return esc(:($string = $rhs))
1818
end
1919
macro string_prepend!(input1, input2, string)
2020
rhs = :($input1 * $input2 * $string)
21-
esc(:($string = $rhs))
21+
return esc(:($string = $rhs))
2222
end
2323

2424
# Gets the character at a specific index.
@@ -51,18 +51,18 @@ function push_field(file_text::String, rn::ReactionSystem,
5151

5252
# Adds (potential) annotation. Returns the expanded file text, and a Bool that this field was added.
5353
annotate && (@string_prepend! "\n\n# " get_comp_annotation(rn) write_string)
54-
(file_text * write_string, true)
54+
return (file_text * write_string, true)
5555
end
5656

5757
# Generic function for creating an string for a unsupported argument.
5858
function get_unsupported_comp_string(component::String)
5959
@warn "Writing ReactionSystem models with $(component) is currently not supported. This field is not written to the file."
60-
""
60+
return ""
6161
end
6262

6363
# Generic function for creating the annotation string for an unsupported argument.
6464
function get_unsupported_comp_annotation(component::String)
65-
"$(component): (OBS: Currently not supported, and hence empty)"
65+
return "$(component): (OBS: Currently not supported, and hence empty)"
6666
end
6767

6868
### String Conversion ###
@@ -72,14 +72,14 @@ end
7272
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)
75-
repr(strip_called_expr)
75+
return repr(strip_called_expr)
7676
end
7777

7878
# Converts a vector of symbolics (e.g. the species or parameter vectors) to a string vector. Strips
7979
# any calls (e.g. X(t) becomes X). E.g. a species vector [X, Y, Z] is converted to "[X, Y, Z]".
8080
function syms_2_strings(syms)
8181
strip_called_syms = [strip_call(Symbolics.unwrap(sym)) for sym in syms]
82-
get_substring_end("$(convert(Vector{Any}, strip_called_syms))", 4, 0)
82+
return get_substring_end("$(convert(Vector{Any}, strip_called_syms))", 4, 0)
8383
end
8484

8585
# Converts a vector of symbolic variables (e.g. the species or parameter vectors) to a string

src/reactionsystem_serialisation/serialise_fields.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
# Checks if the reaction system has any independent variable. True for all valid reaction systems.
44
function seri_has_iv(rn::ReactionSystem)
5-
true
5+
return true
66
end
77

88
# Extract a string which declares the system's independent variable.
99
function get_iv_string(rn::ReactionSystem)
1010
iv_dec = MT.get_iv(rn)
11-
"@variables $(iv_dec)"
11+
return "@variables $(iv_dec)"
1212
end
1313

1414
# Creates an annotation for the system's independent variable.
1515
function get_iv_annotation(rn::ReactionSystem)
16-
"Independent variable:"
16+
return "Independent variable:"
1717
end
1818

1919
# Combines the 3 independent variable-related functions in a constant tuple.
@@ -23,17 +23,17 @@ IV_FS = (seri_has_iv, get_iv_string, get_iv_annotation)
2323

2424
# Checks if the reaction system has any spatial independent variables.
2525
function seri_has_sivs(rn::ReactionSystem)
26-
!isempty(get_sivs(rn))
26+
return !isempty(get_sivs(rn))
2727
end
2828

2929
# Extract a string which declares the system's spatial independent variables.
3030
function get_sivs_string(rn::ReactionSystem)
31-
"spatial_ivs = @variables$(syms_2_declaration_string(get_sivs(rn)))"
31+
return "spatial_ivs = @variables$(syms_2_declaration_string(get_sivs(rn)))"
3232
end
3333

3434
# Creates an annotation for the system's spatial independent variables.
3535
function get_sivs_annotation(rn::ReactionSystem)
36-
"Spatial independent variables:"
36+
return "Spatial independent variables:"
3737
end
3838

3939
# Combines the 3 independent variables-related functions in a constant tuple.
@@ -133,7 +133,7 @@ function handle_us_n_ps(file_text::String, rn::ReactionSystem, annotate::Bool,
133133
end
134134

135135
# Merges the file text with `us_n_ps_string` and returns the final outputs.
136-
file_text * us_n_ps_string, has_ps, has_sps, has_vars
136+
return file_text * us_n_ps_string, has_ps, has_sps, has_vars
137137
end
138138

139139
### Handles Parameters ###
@@ -142,20 +142,20 @@ end
142142

143143
# Checks if the reaction system has any parameters.
144144
function seri_has_parameters(rn::ReactionSystem)
145-
!isempty(get_ps(rn))
145+
return !isempty(get_ps(rn))
146146
end
147147

148148
# Extract a string which declares the system's parameters. Uses multiline declaration (a
149149
# `begin ... end` block) if more than 3 parameters have a "complicated" declaration (if they
150150
# have metadata, default value, or type designation).
151151
function get_parameters_string(ps)
152152
multiline_format = count(complicated_declaration(p) for p in ps) > 3
153-
"@parameters$(syms_2_declaration_string(ps; multiline_format))"
153+
return "@parameters$(syms_2_declaration_string(ps; multiline_format))"
154154
end
155155

156156
# Creates an annotation for the system's parameters.
157157
function get_parameters_annotation(rn::ReactionSystem)
158-
"Parameters:"
158+
return "Parameters:"
159159
end
160160

161161
### Handles Species ###
@@ -164,20 +164,20 @@ end
164164

165165
# Checks if the reaction system has any species.
166166
function seri_has_species(rn::ReactionSystem)
167-
!isempty(get_species(rn))
167+
return !isempty(get_species(rn))
168168
end
169169

170170
# Extract a string which declares the system's species. Uses multiline declaration (a
171171
# `begin ... end` block) if more than 3 species have a "complicated" declaration (if they
172172
# have metadata, default value, or type designation).
173173
function get_species_string(sps)
174174
multiline_format = count(complicated_declaration(sp) for sp in sps) > 3
175-
"@species$(syms_2_declaration_string(sps; multiline_format))"
175+
return "@species$(syms_2_declaration_string(sps; multiline_format))"
176176
end
177177

178178
# Creates an annotation for the system's species.
179179
function get_species_annotation(rn::ReactionSystem)
180-
"Species:"
180+
return "Species:"
181181
end
182182

183183
### Handles Variables ###

0 commit comments

Comments
 (0)