Skip to content

Commit cdbc943

Browse files
Fix awkward line splits from JuliaFormatter
- Keep tuple assignments (fig, ax, plt) on single lines - Fix split function calls and constant definitions - Improve readability by keeping related elements together - Binary operations with long warnings kept more readable These changes address formatting issues introduced by JuliaFormatter that made the code less readable by splitting logical units across lines.
1 parent e718736 commit cdbc943

File tree

6 files changed

+17
-32
lines changed

6 files changed

+17
-32
lines changed

ext/CatalystCairoMakieExtension/cairo_makie_extension_spatial_modelling.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ function lattice_animation(
2424
vals, plot_min, plot_max = Catalyst.extract_vals(sol, sp, lrs, plot_min, plot_max, t)
2525

2626
# Creates the base figure (which is modified in the animation).
27-
fig, ax,
28-
plt = scatterlines(vals[1];
27+
fig, ax, plt = scatterlines(vals[1];
2928
axis = (xlabel = "Compartment", ylabel = "$(sp)",
3029
limits = (nothing, nothing, plot_min, plot_max)),
3130
markersize = markersize, kwargs...)
@@ -101,8 +100,7 @@ function lattice_animation(
101100
x_vals, y_vals = Catalyst.extract_grid_axes(lrs)
102101

103102
# Creates the base figure (which is modified in the animation).
104-
fig, ax,
105-
hm = heatmap(x_vals, y_vals, vals[1];
103+
fig, ax, hm = heatmap(x_vals, y_vals, vals[1];
106104
axis = (xgridvisible = false, ygridvisible = false,
107105
xlabel = "Compartment", ylabel = "Compartment"),
108106
colormap, colorrange = (plot_min, plot_max),

ext/CatalystGraphMakieExtension/graph_makie_extension_spatial_modelling.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ function lattice_animation(
2727
vals, plot_min, plot_max = Catalyst.extract_vals(sol, sp, lrs, plot_min, plot_max, t)
2828

2929
# Creates the base figure (which is modified in the animation).
30-
fig, ax,
31-
plt = graphplot(plot_graph; node_color = vals[1],
32-
node_attr = (colorrange = (plot_min, plot_max), colormap), node_size, kwargs...
33-
)
30+
fig, ax, plt = graphplot(plot_graph; node_color = vals[1],
31+
node_attr = (colorrange = (plot_min, plot_max), colormap), node_size, kwargs...)
3432
ttitle && (ax.title = "Time: $(round(t[1]; sigdigits = 3))")
3533

3634
# Creates the animation.

src/chemistry_functionality.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,7 @@ function balance_reaction(reaction::Reaction)
275275
end
276276

277277
isempty(balancedrxs) && (@warn "Unable to balance reaction.")
278-
(length(balancedrxs) > 1) &&
279-
(@warn "The space of possible balanced versions of the reaction ($reaction) is greater than one-dimension. This prevents the selection of a single appropriate balanced reaction. Instead, a basis for balanced reactions is returned. Note that we do not check if they preserve the set of substrates and products from the original reaction.")
278+
(length(balancedrxs) > 1) && (@warn "The space of possible balanced versions of the reaction ($reaction) is greater than one-dimension. This prevents the selection of a single appropriate balanced reaction. Instead, a basis for balanced reactions is returned. Note that we do not check if they preserve the set of substrates and products from the original reaction.")
280279
return balancedrxs
281280
end
282281

src/dsl.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
# Declare various arrow types symbols used for the empty set (also 0).
44
const empty_set = Set{Symbol}([:∅, ])
55
const fwd_arrows = Set{Symbol}([:>, :(=>), :, :, :, :, :, :, :, :, :, :, :, :])
6-
const bwd_arrows = Set{Symbol}([:<, :(<=), :, :, :, :, :, :, :, :, :, :, :, :,
7-
Symbol("<--")])
6+
const bwd_arrows = Set{Symbol}([:<, :(<=), :, :, :, :, :, :, :, :, :, :, :, :, Symbol("<--")])
87
const double_arrows = Set{Symbol}([:, :, :, :, :, :, :, :, Symbol("<-->")])
98
const pure_rate_arrows = Set{Symbol}([:(=>), :(<=), :, :, :, :, :, :])
109

1110
# Declares the keys used for various options.
1211
const option_keys = (:species, :parameters, :variables, :ivs, :compounds, :observables,
13-
:default_noise_scaling, :differentials, :equations,
14-
:continuous_events, :discrete_events, :combinatoric_ratelaws, :require_declaration)
12+
:default_noise_scaling, :differentials, :equations, :continuous_events, :discrete_events,
13+
:combinatoric_ratelaws, :require_declaration)
1514

1615
### `@species` Macro ###
1716

@@ -298,14 +297,12 @@ function make_reaction_system(ex::Expr, name)
298297
requiredec = haskey(options, :require_declaration)
299298
reactions = get_reactions(reaction_lines)
300299
sps_inferred, ps_pre_inferred = extract_sps_and_ps(reactions, syms_declared; requiredec)
301-
vs_inferred, diffs_inferred,
302-
equations = read_equations_option!(diffsexpr, options,
300+
vs_inferred, diffs_inferred, equations = read_equations_option!(diffsexpr, options,
303301
union(syms_declared, sps_inferred), tiv; requiredec)
304302
ps_inferred = setdiff(ps_pre_inferred, vs_inferred, diffs_inferred)
305303
syms_inferred = union(sps_inferred, ps_inferred, vs_inferred, diffs_inferred)
306304
all_syms = union(syms_declared, syms_inferred)
307-
obsexpr, obs_eqs,
308-
obs_syms = read_observables_option(options, ivs,
305+
obsexpr, obs_eqs, obs_syms = read_observables_option(options, ivs,
309306
union(sps_declared, vs_declared), all_syms; requiredec)
310307

311308
# Read options not related to the declaration or inference of symbols.

src/reaction.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,7 @@ Notes: The following values are possible:
702702
end
703703

704704
const JUMP_SCALES = (PhysicalScale.Jump, PhysicalScale.VariableRateJump)
705-
const NON_CONSTANT_JUMP_SCALES = (
706-
PhysicalScale.ODE, PhysicalScale.SDE, PhysicalScale.VariableRateJump)
705+
const NON_CONSTANT_JUMP_SCALES = (PhysicalScale.ODE, PhysicalScale.SDE, PhysicalScale.VariableRateJump)
707706

708707
"""
709708
has_physical_scale(rx::Reaction)

src/reactionsystem_serialisation/serialise_fields.jl

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,9 @@ function handle_us_n_ps(file_text::String, rn::ReactionSystem, annotate::Bool,
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,
106-
[remaining_ps; remaining_sps; remaining_vars])
107-
writable_sps = dependency_split!(remaining_sps,
108-
[remaining_ps; remaining_sps; remaining_vars])
109-
writable_vars = dependency_split!(remaining_vars,
110-
[remaining_ps; remaining_sps; remaining_vars])
105+
writable_ps = dependency_split!(remaining_ps, [remaining_ps; remaining_sps; remaining_vars])
106+
writable_sps = dependency_split!(remaining_sps, [remaining_ps; remaining_sps; remaining_vars])
107+
writable_vars = dependency_split!(remaining_vars, [remaining_ps; remaining_sps; remaining_vars])
111108

112109
# Writes those that can be written.
113110
isempty(writable_ps) ||
@@ -430,8 +427,7 @@ function get_continuous_events_annotation(rn::ReactionSystem)
430427
end
431428

432429
# Combines the 3 -related functions in a constant tuple.
433-
CONTINUOUS_EVENTS_FS = (seri_has_continuous_events, get_continuous_events_string,
434-
get_continuous_events_annotation)
430+
CONTINUOUS_EVENTS_FS = (seri_has_continuous_events, get_continuous_events_string, get_continuous_events_annotation)
435431

436432
### Handles Discrete Events ###
437433

@@ -487,8 +483,7 @@ function get_discrete_events_annotation(rn::ReactionSystem)
487483
end
488484

489485
# Combines the 3 -related functions in a constant tuple.
490-
DISCRETE_EVENTS_FS = (seri_has_discrete_events, get_discrete_events_string,
491-
get_discrete_events_annotation)
486+
DISCRETE_EVENTS_FS = (seri_has_discrete_events, get_discrete_events_string, get_discrete_events_annotation)
492487

493488
### Handles Systems ###
494489

@@ -563,5 +558,4 @@ function get_connection_type_annotation(rn::ReactionSystem)
563558
end
564559

565560
# Combines the 3 connection types-related functions in a constant tuple.
566-
CONNECTION_TYPE_FS = (
567-
seri_has_connection_type, get_connection_type_string, get_connection_type_annotation)
561+
CONNECTION_TYPE_FS = (seri_has_connection_type, get_connection_type_string, get_connection_type_annotation)

0 commit comments

Comments
 (0)