Skip to content

Commit 32cb860

Browse files
committed
Revert "format"
This reverts commit 50ec948.
1 parent 0735fd7 commit 32cb860

File tree

14 files changed

+126
-155
lines changed

14 files changed

+126
-155
lines changed

docs/make.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ makedocs(sitename = "Catalyst.jl",
4040
collapselevel = 1,
4141
assets = ["assets/favicon.ico"],
4242
canonical = "https://docs.sciml.ai/Catalyst/stable/"),
43-
modules = [Catalyst, ModelingToolkit,
44-
isdefined(Base, :get_extension) ?
45-
Base.get_extension(Catalyst, :CatalystGraphMakieExtension) :
46-
Catalyst.CatalystGraphMakieExtension],
43+
modules = [Catalyst, ModelingToolkit,
44+
isdefined(Base, :get_extension) ? Base.get_extension(Catalyst, :CatalystGraphMakieExtension) :
45+
Catalyst.CatalystGraphMakieExtension],
4746
doctest = false,
4847
clean = true,
4948
pages = pages,

docs/pages.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ pages = Any[
7575
],
7676
"FAQs" => "faqs.md",
7777
"API" => Any[
78-
"api/core_api.md",
79-
"api/network_analysis_api.md"
80-
],
78+
"api/core_api.md",
79+
"api/network_analysis_api.md"
80+
],
8181
"Developer Documentation" => "devdocs/dev_guide.md"
8282
]

ext/CatalystCairoMakieExtension/cairo_makie_extension_spatial_modelling.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ function lattice_animation(
101101

102102
# Creates the base figure (which is modified in the animation).
103103
fig, ax, hm = heatmap(x_vals, y_vals, vals[1];
104-
axis = (xgridvisible = false, ygridvisible = false,
105-
xlabel = "Compartment", ylabel = "Compartment"),
104+
axis = (xgridvisible = false, ygridvisible = false, xlabel = "Compartment", ylabel = "Compartment"),
106105
colormap, colorrange = (plot_min, plot_max),
107106
kwargs...)
108107
ttitle && (ax.title = "Time: $(round(t[1]; sigdigits = 3))")

ext/CatalystGraphMakieExtension/rn_graph_plot.jl

Lines changed: 68 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,29 @@ Wrapper intended to allow plotting of multiple edges. This is needed in the foll
1212
`gen_distances` sets the distances between the edges that allows multiple to be visible on the plot at the same time.
1313
"""
1414
struct MultiGraphWrap{T} <: Graphs.AbstractGraph{T}
15-
g::SimpleDiGraph{T}
16-
multiedges::Vector{Graphs.SimpleEdge{T}}
17-
"""Sets the drawing order of the edges. Needed because multiedges need to be consecutive to be drawn properly."""
18-
edgeorder::Vector{Int64}
15+
g::SimpleDiGraph{T}
16+
multiedges::Vector{Graphs.SimpleEdge{T}}
17+
"""Sets the drawing order of the edges. Needed because multiedges need to be consecutive to be drawn properly."""
18+
edgeorder::Vector{Int64}
1919
end
2020

2121
# Create the SimpleDiGraph corresponding to the species and reactions, the species-reaction graph
22-
function SRGraphWrap(rn::ReactionSystem)
22+
function SRGraphWrap(rn::ReactionSystem)
2323
srg = species_reaction_graph(rn)
2424
multiedges = Vector{Graphs.SimpleEdge{Int}}()
2525
sm = speciesmap(rn)
2626
specs = species(rn)
2727

2828
deps = Set()
29-
for (i, rx) in enumerate(reactions(rn))
29+
for (i, rx) in enumerate(reactions(rn))
3030
empty!(deps)
3131
get_variables!(deps, rx.rate, specs)
3232
if !isempty(deps)
33-
for spec in deps
33+
for spec in deps
3434
specidx = sm[spec]
35-
has_edge(srg, specidx, i + length(specs)) ?
36-
push!(multiedges, Graphs.SimpleEdge(specidx, i + length(specs))) :
37-
add_edge!(srg, Graphs.SimpleEdge(specidx, i + length(specs)))
35+
has_edge(srg, specidx, i + length(specs)) ?
36+
push!(multiedges, Graphs.SimpleEdge(specidx, i + length(specs))) :
37+
add_edge!(srg, Graphs.SimpleEdge(specidx, i + length(specs)))
3838
end
3939
end
4040
end
@@ -44,17 +44,16 @@ function SRGraphWrap(rn::ReactionSystem)
4444
end
4545

4646
# Automatically set edge drawing order if not supplied
47-
function MultiGraphWrap(
48-
g::SimpleDiGraph{T}, multiedges::Vector{Graphs.SimpleEdge{T}}) where {T}
47+
function MultiGraphWrap(g::SimpleDiGraph{T}, multiedges::Vector{Graphs.SimpleEdge{T}}) where T
4948
edgelist = vcat(collect(Graphs.edges(g)), multiedges)
5049
edgeorder = sortperm(edgelist)
5150
MultiGraphWrap(g, multiedges, edgeorder)
5251
end
5352

5453
# Return the multigraph and reaction order corresponding to the complex graph. The reaction order is the order of reactions(rn) that would match the edge order given by g.edgeorder.
55-
function ComplexGraphWrap(rn::ReactionSystem)
54+
function ComplexGraphWrap(rn::ReactionSystem)
5655
img = incidencematgraph(rn)
57-
D = incidencemat(rn; sparse = true)
56+
D = incidencemat(rn; sparse=true)
5857
specs = species(rn)
5958
rxs = reactions(rn)
6059

@@ -79,7 +78,7 @@ function ComplexGraphWrap(rn::ReactionSystem)
7978
edgelist = edgelist[rxorder]
8079
multiedges = Vector{Graphs.SimpleEdge{Int}}()
8180
for i in 2:length(edgelist)
82-
isequal(edgelist[i], edgelist[i - 1]) && push!(multiedges, edgelist[i])
81+
isequal(edgelist[i], edgelist[i-1]) && push!(multiedges, edgelist[i])
8382
end
8483
MultiGraphWrap(img, multiedges), rxorder
8584
end
@@ -88,16 +87,16 @@ Base.eltype(g::MultiGraphWrap) = eltype(g.g)
8887
Graphs.edgetype(g::MultiGraphWrap) = edgetype(g.g)
8988
Graphs.has_edge(g::MultiGraphWrap, s, d) = has_edge(g.g, s, d)
9089
Graphs.has_vertex(g::MultiGraphWrap, i) = has_vertex(g.g, i)
91-
Graphs.inneighbors(g::MultiGraphWrap{T}, i) where {T} = inneighbors(g.g, i)
92-
Graphs.outneighbors(g::MultiGraphWrap{T}, i) where {T} = outneighbors(g.g, i)
90+
Graphs.inneighbors(g::MultiGraphWrap{T}, i) where T = inneighbors(g.g, i)
91+
Graphs.outneighbors(g::MultiGraphWrap{T}, i) where T = outneighbors(g.g, i)
9392
Graphs.ne(g::MultiGraphWrap) = length(g.multiedges) + length(Graphs.edges(g.g))
9493
Graphs.nv(g::MultiGraphWrap) = nv(g.g)
9594
Graphs.vertices(g::MultiGraphWrap) = vertices(g.g)
9695
Graphs.is_directed(::Type{<:MultiGraphWrap}) = true
9796
Graphs.is_directed(g::MultiGraphWrap) = is_directed(g.g)
9897
Graphs.is_connected(g::MultiGraphWrap) = is_connected(g.g)
9998

100-
function Graphs.adjacency_matrix(g::MultiGraphWrap)
99+
function Graphs.adjacency_matrix(g::MultiGraphWrap)
101100
adj = Graphs.adjacency_matrix(g.g)
102101
for e in g.multiedges
103102
adj[src(e), dst(e)] = 1
@@ -109,32 +108,32 @@ function Graphs.edges(g::MultiGraphWrap)
109108
edgelist = vcat(collect(Graphs.edges(g.g)), g.multiedges)[g.edgeorder]
110109
end
111110

112-
function gen_distances(g::MultiGraphWrap; inc = 0.2)
111+
function gen_distances(g::MultiGraphWrap; inc = 0.2)
113112
edgelist = edges(g)
114113
distances = zeros(length(edgelist))
115114
edgedict = Dict(edgelist[1] => [1])
116115
for (i, e) in enumerate(@view edgelist[2:end])
117-
if edgelist[i] != edgelist[i + 1]
118-
edgedict[e] = [i + 1]
116+
if edgelist[i] != edgelist[i+1]
117+
edgedict[e] = [i+1]
119118
else
120-
push!(edgedict[e], i + 1)
119+
push!(edgedict[e], i+1)
121120
end
122121
end
123122

124123
for (edge, inds) in edgedict
125124
if haskey(edgedict, Edge(dst(edge), src(edge)))
126-
distances[inds[1]] != 0.0 && continue
125+
distances[inds[1]] != 0. && continue
127126
inds_ = edgedict[Edge(dst(edge), src(edge))]
128127

129128
len = length(inds) + length(inds_)
130-
sp = -inc / 2 * (len - 1)
131-
ep = sp + inc * (len - 1)
129+
sp = -inc/2*(len-1)
130+
ep = sp + inc*(len-1)
132131
dists = collect(sp:inc:ep)
133132
distances[inds] = dists[1:length(inds)]
134-
distances[inds_] = -dists[(length(inds) + 1):end]
133+
distances[inds_] = -dists[length(inds)+1:end]
135134
else
136-
sp = -inc / 2 * (length(inds) - 1)
137-
ep = sp + inc * (length(inds) - 1)
135+
sp = -inc/2*(length(inds)-1)
136+
ep = sp + inc*(length(inds)-1)
138137
distances[inds] = collect(sp:inc:ep)
139138
end
140139
end
@@ -159,30 +158,30 @@ Notes:
159158
red and black arrows from `A` to the reaction node.
160159
161160
For a list of accepted keyword arguments to the graph plot, please see the [GraphMakie documentation](https://graph.makie.org/stable/#The-graphplot-Recipe).
162-
"""
161+
"""
163162
function Catalyst.plot_network(rn::ReactionSystem; kwargs...)
164163
srg = SRGraphWrap(rn)
165164
ns = length(species(rn))
166-
nodecolors = vcat([:skyblue3 for i in 1:ns],
167-
[:green for i in (ns + 1):nv(srg)])
168-
ilabels = vcat(map(s -> String(tosymbol(s, escape = false)), species(rn)),
169-
["R$i" for i in 1:(nv(srg) - ns)])
165+
nodecolors = vcat([:skyblue3 for i in 1:ns],
166+
[:green for i in ns+1:nv(srg)])
167+
ilabels = vcat(map(s -> String(tosymbol(s, escape=false)), species(rn)),
168+
["R$i" for i in 1:nv(srg)-ns])
170169

171170
ssm = substoichmat(rn)
172171
psm = prodstoichmat(rn)
173172
# Get stoichiometry of reaction
174173
edgelabels = map(Graphs.edges(srg.g)) do e
175-
string(src(e) > ns ?
176-
psm[dst(e), src(e) - ns] :
177-
ssm[src(e), dst(e) - ns])
178-
end
174+
string(src(e) > ns ?
175+
psm[dst(e), src(e)-ns] :
176+
ssm[src(e), dst(e)-ns])
177+
end
179178
edgecolors = [:black for i in 1:ne(srg)]
180179

181180
num_e = ne(srg.g)
182181
# Handle the rate edges
183182
for i in 1:length(srg.edgeorder)
184183
# If there are stoichiometry and rate edges from the same species to reaction
185-
if srg.edgeorder[i] > num_e
184+
if srg.edgeorder[i] > num_e
186185
edgecolors[i] = :red
187186
insert!(edgelabels, i, "")
188187
elseif edgelabels[i] == "0"
@@ -191,29 +190,29 @@ function Catalyst.plot_network(rn::ReactionSystem; kwargs...)
191190
end
192191
end
193192

194-
layout = if !haskey(kwargs, :layout)
193+
layout = if !haskey(kwargs, :layout)
195194
Stress()
196195
end
197-
f = graphplot(srg;
198-
layout,
199-
edge_color = edgecolors,
200-
elabels = edgelabels,
201-
elabels_rotation = 0,
202-
ilabels = ilabels,
203-
node_color = nodecolors,
204-
arrow_shift = :end,
205-
arrow_size = 20,
206-
curve_distance_usage = true,
207-
curve_distance = gen_distances(srg),
208-
kwargs...
209-
)
196+
f = graphplot(srg;
197+
layout,
198+
edge_color = edgecolors,
199+
elabels = edgelabels,
200+
elabels_rotation = 0,
201+
ilabels = ilabels,
202+
node_color = nodecolors,
203+
arrow_shift = :end,
204+
arrow_size = 20,
205+
curve_distance_usage = true,
206+
curve_distance = gen_distances(srg),
207+
kwargs...
208+
)
210209

211210
f.axis.xautolimitmargin = (0.15, 0.15)
212211
f.axis.yautolimitmargin = (0.15, 0.15)
213212
hidedecorations!(f.axis)
214213
hidespines!(f.axis)
215214
f.axis.aspect = DataAspect()
216-
215+
217216
f
218217
end
219218

@@ -249,21 +248,21 @@ function Catalyst.plot_complexes(rn::ReactionSystem; show_rate_labels = false, k
249248
# Get complex graph and reaction order for edgecolors and edgelabels. rxorder gives the order of reactions(rn) that would match the edge order in edges(cg).
250249
cg, rxorder = ComplexGraphWrap(rn)
251250

252-
layout = if !haskey(kwargs, :layout)
251+
layout = if !haskey(kwargs, :layout)
253252
Stress()
254253
end
255254
f = graphplot(cg;
256-
layout,
257-
edge_color = edgecolors[rxorder],
258-
elabels = show_rate_labels ? edgelabels[rxorder] : [],
259-
ilabels = complexlabels(rn),
260-
node_color = :skyblue3,
261-
elabels_rotation = 0,
262-
arrow_shift = :end,
263-
curve_distance_usage = true,
264-
curve_distance = gen_distances(cg),
265-
kwargs...
266-
)
255+
layout,
256+
edge_color = edgecolors[rxorder],
257+
elabels = show_rate_labels ? edgelabels[rxorder] : [],
258+
ilabels = complexlabels(rn),
259+
node_color = :skyblue3,
260+
elabels_rotation = 0,
261+
arrow_shift = :end,
262+
curve_distance_usage = true,
263+
curve_distance = gen_distances(cg),
264+
kwargs...
265+
)
267266

268267
f.axis.xautolimitmargin = (0.15, 0.15)
269268
f.axis.yautolimitmargin = (0.15, 0.15)
@@ -274,9 +273,9 @@ function Catalyst.plot_complexes(rn::ReactionSystem; show_rate_labels = false, k
274273
f
275274
end
276275

277-
function complexelem_tostr(e::Catalyst.ReactionComplexElement, specstrs)
276+
function complexelem_tostr(e::Catalyst.ReactionComplexElement, specstrs)
278277
if e.speciesstoich == 1
279-
return "$(specstrs[e.speciesid])"
278+
return "$(specstrs[e.speciesid])"
280279
else
281280
return "$(e.speciesstoich)$(specstrs[e.speciesid])"
282281
end
@@ -286,11 +285,11 @@ end
286285
function complexlabels(rn::ReactionSystem)
287286
labels = String[]
288287

289-
specstrs = map(s -> String(tosymbol(s, escape = false)), species(rn))
288+
specstrs = map(s -> String(tosymbol(s, escape=false)), species(rn))
290289
complexes, B = reactioncomplexes(rn)
291290

292291
for complex in complexes
293-
if isempty(complex)
292+
if isempty(complex)
294293
push!(labels, "")
295294
elseif length(complex) == 1
296295
push!(labels, complexelem_tostr(complex[1], specstrs))

ext/CatalystHomotopyContinuationExtension/homotopy_continuation_extension.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ function common_denominator(expr)
139139
den ^= pow
140140
return num / den
141141
end
142-
return maketerm(BasicSymbolic, operation(expr),
143-
map(common_denominator, arguments(expr)), metadata(expr))
142+
return maketerm(BasicSymbolic, operation(expr), map(common_denominator, arguments(expr)), metadata(expr))
144143
end
145144

146145
# If the input is a fraction, removes the denominator.

src/Catalyst.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ export @reaction_network, @network_component, @reaction, @species
110110
# Network analysis functionality.
111111
include("network_analysis.jl")
112112
export reactioncomplexmap, reactioncomplexes, incidencemat
113-
export complexstoichmat, laplacianmat, fluxmat, massactionvector, complexoutgoingmat,
114-
adjacencymat
113+
export complexstoichmat, laplacianmat, fluxmat, massactionvector, complexoutgoingmat, adjacencymat
115114
export incidencematgraph, linkageclasses, stronglinkageclasses,
116115
terminallinkageclasses, deficiency, subnetworks
117116
export linkagedeficiencies, isreversible, isweaklyreversible

src/chemistry_functionality.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,10 @@ function make_compound(expr)
103103

104104
# If no ivs were given, inserts an expression which evaluates to the union of the ivs
105105
# for the species the compound depends on.
106-
ivs_get_expr = :(unique(reduce(
107-
vcat, (sorted_arguments(ModelingToolkit.unwrap(comp))
106+
ivs_get_expr = :(unique(reduce( vcat, (sorted_arguments(ModelingToolkit.unwrap(comp))
108107
for comp in $components))))
109108
if isempty(ivs)
110-
species_expr = Catalyst.insert_independent_variable(
111-
species_expr, :($ivs_get_expr...))
109+
species_expr = Catalyst.insert_independent_variable(species_expr, :($ivs_get_expr...))
112110
end
113111

114112
# Creates the found expressions that will create the compound species.

0 commit comments

Comments
 (0)