Skip to content

Commit 68599d3

Browse files
Merge pull request #507 from SciML/fix-formatter-line-splits
Fix unnecessary line splits following Catalyst.jl PR #1306
2 parents 1f2fcbf + b52c3fa commit 68599d3

File tree

11 files changed

+33
-68
lines changed

11 files changed

+33
-68
lines changed

docs/make.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ cp(joinpath(docpath, "Project.toml"), joinpath(assetpath, "Project.toml"), force
1212

1313
include("pages.jl")
1414

15-
mathengine = MathJax3(Dict(:loader => Dict("load" => ["[tex]/require", "[tex]/mathtools"]),
16-
:tex => Dict("inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
15+
mathengine = MathJax3(Dict(:loader => Dict("load" => ["[tex]/require", "[tex]/mathtools"]), :tex => Dict("inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
1716
"packages" => [
1817
"base",
1918
"ams",
@@ -22,9 +21,7 @@ mathengine = MathJax3(Dict(:loader => Dict("load" => ["[tex]/require", "[tex]/ma
2221
"require"
2322
])))
2423

25-
makedocs(sitename = "JumpProcesses.jl",
26-
authors = "Chris Rackauckas",
27-
modules = [JumpProcesses],
24+
makedocs(sitename = "JumpProcesses.jl", authors = "Chris Rackauckas", modules = [JumpProcesses],
2825
clean = true, doctest = false, linkcheck = true, warnonly = [:missing_docs],
2926
format = Documenter.HTML(; assets = ["assets/favicon.ico"],
3027
canonical = "https://docs.sciml.ai/JumpProcesses/",
@@ -36,5 +33,4 @@ makedocs(sitename = "JumpProcesses.jl",
3633
repolink = "https://github.com/SciML/JumpProcesses.jl"),
3734
pages = pages)
3835

39-
deploydocs(repo = "github.com/SciML/JumpProcesses.jl.git";
40-
push_preview = true)
36+
deploydocs(repo = "github.com/SciML/JumpProcesses.jl.git"; push_preview = true)

src/coupling.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ function build_split_jumps(prob::DiffEqBase.AbstractJumpProblem,
158158
push!(jumps, ConstantRateJump(new_rate, new_affect!))
159159
# only prob
160160
new_affect! = affect!
161-
new_rate = (u, p,
162-
t) -> rate(u.u, p, t) -
161+
new_rate = (u, p, t) -> rate(u.u, p, t) -
163162
min(rate(u.u, p, t), rate_control(u.u_control, p, t))
164163
push!(jumps, ConstantRateJump(new_rate, new_affect!))
165164
# only prob_control
@@ -168,9 +167,7 @@ function build_split_jumps(prob::DiffEqBase.AbstractJumpProblem,
168167
affect!(integrator)
169168
flip_u!(integrator.u)
170169
end
171-
new_rate = (u,
172-
p,
173-
t) -> rate_control(u.u_control, p, t) -
170+
new_rate = (u, p, t) -> rate_control(u.u_control, p, t) -
174171
min(rate(u.u, p, t), rate_control(u.u_control, p, t))
175172
push!(jumps, ConstantRateJump(new_rate, new_affect!))
176173
end

src/jumps.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,11 @@ p = (β=1e-4, ν=.01)
300300
u0 = [999, 1, 0] # (S,I,R)
301301
tspan = (0.0, 250.0)
302302
rateidxs = [1, 2] # i.e. [β,ν]
303-
reactant_stoich =
304-
[
303+
reactant_stoich = [
305304
[1 => 1, 2 => 1], # 1*S and 1*I
306305
[2 => 1] # 1*I
307306
]
308-
net_stoich =
309-
[
307+
net_stoich = [
310308
[1 => -1, 2 => 1], # -1*S and 1*I
311309
[2 => -1, 3 => 1] # -1*I and 1*R
312310
]

src/spatial/flatten.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ function flatten(netstoch::AbstractArray, reactstoch::AbstractArray,
4747
hop_constants = Matrix{Vector{F}}(undef, size(hopping_constants))
4848
for ci in CartesianIndices(hop_constants)
4949
(species, site) = Tuple(ci)
50-
hop_constants[ci] = hopping_constants[species, site] *
51-
ones(outdegree(spatial_system, site))
50+
hop_constants[ci] = hopping_constants[species, site] * ones(outdegree(spatial_system, site))
5251
end
5352
flatten(netstoch, reactstoch, rx_rates, spatial_system, u0, tspan, hop_constants;
5453
kwargs...)

src/spatial/hop_rates.jl

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ end
157157
return hopping rate of species at site
158158
"""
159159
function evalhoprate(hop_rates::HopRatesGraphDs, u, species, site, spatial_system)
160-
@inbounds u[species, site] * hop_rates.hopping_constants[species] *
161-
outdegree(spatial_system, site)
160+
@inbounds u[species, site] * hop_rates.hopping_constants[species] * outdegree(spatial_system, site)
162161
end
163162

164163
############## hopping rates of form D_{s,i} ################
@@ -197,8 +196,7 @@ end
197196
return hopping rate of species at site
198197
"""
199198
function evalhoprate(hop_rates::HopRatesGraphDsi, u, species, site, spatial_system)
200-
@inbounds u[species, site] * hop_rates.hopping_constants[species, site] *
201-
outdegree(spatial_system, site)
199+
@inbounds u[species, site] * hop_rates.hopping_constants[species, site] * outdegree(spatial_system, site)
202200
end
203201

204202
############## hopping rates of form D_{s,i,j} ################
@@ -344,8 +342,7 @@ function sample_target_site(hop_rates::HopRatesGraphDsLij, site, species, rng,
344342
end
345343

346344
function evalhoprate(hop_rates::HopRatesGraphDsLij, u, species, site, spatial_system)
347-
@inbounds u[species, site] * hop_rates.species_hop_constants[species] *
348-
hop_rates.hop_const_cumulative_sums[site][end]
345+
@inbounds u[species, site] * hop_rates.species_hop_constants[species] * hop_rates.hop_const_cumulative_sums[site][end]
349346
end
350347

351348
############## hopping rates of form D_s * L_{i,j} optimized for cartesian grid ################
@@ -398,8 +395,7 @@ function sample_target_site(hop_rates::HopRatesGridDsLij, site, species, rng, gr
398395
end
399396

400397
function evalhoprate(hop_rates::HopRatesGridDsLij, u, species, site, grid)
401-
@inbounds u[species, site] * hop_rates.species_hop_constants[species] *
402-
hop_rates.hop_const_cumulative_sums[end, site]
398+
@inbounds u[species, site] * hop_rates.species_hop_constants[species] * hop_rates.hop_const_cumulative_sums[end, site]
403399
end
404400

405401
############## hopping rates of form D_{s,i} * L_{i,j} ################
@@ -441,8 +437,7 @@ function sample_target_site(hop_rates::HopRatesGraphDsiLij, site, species, rng,
441437
end
442438

443439
function evalhoprate(hop_rates::HopRatesGraphDsiLij, u, species, site, spatial_system)
444-
@inbounds u[species, site] * hop_rates.species_hop_constants[species, site] *
445-
hop_rates.hop_const_cumulative_sums[site][end]
440+
@inbounds u[species, site] * hop_rates.species_hop_constants[species, site] * hop_rates.hop_const_cumulative_sums[site][end]
446441
end
447442

448443
############## hopping rates of form D_{s,i} * L_{i,j} optimized for cartesian grid ################
@@ -497,6 +492,5 @@ function sample_target_site(hop_rates::HopRatesGridDsiLij, site, species, rng, g
497492
end
498493

499494
function evalhoprate(hop_rates::HopRatesGridDsiLij, u, species, site, grid)
500-
@inbounds u[species, site] * hop_rates.species_hop_constants[species, site] *
501-
hop_rates.hop_const_cumulative_sums[end, site]
495+
@inbounds u[species, site] * hop_rates.species_hop_constants[species, site] * hop_rates.hop_const_cumulative_sums[end, site]
502496
end

test/bracketing.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ netstoch = [[1 => -1]]
3737
majump = MassActionJump(majump_rates, reactstoch,
3838
netstoch)
3939
reaction_index = 1
40-
@test JP.get_majump_brackets(ulow, uhigh, reaction_index, majump)[1] ==
41-
majump_rates[1] * ulow[1] # low
42-
@test JP.get_majump_brackets(ulow, uhigh, reaction_index, majump)[2] ==
43-
majump_rates[1] * uhigh[1] # high
40+
@test JP.get_majump_brackets(ulow, uhigh, reaction_index, majump)[1] == majump_rates[1] * ulow[1] # low
41+
@test JP.get_majump_brackets(ulow, uhigh, reaction_index, majump)[2] == majump_rates[1] * uhigh[1] # high
4442

4543
# constant rate
4644
rate(u, params, t) = 1 / u[1]

test/degenerate_rx_cases.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ dep_graph = [
9797
]
9898
spec_to_dep_jumps = [[2]]
9999
jump_to_dep_specs = [[1], [1]]
100-
namedpars = (dep_graph = dep_graph, vartojumps_map = spec_to_dep_jumps,
101-
jumptovars_map = jump_to_dep_specs)
100+
namedpars = (dep_graph = dep_graph, vartojumps_map = spec_to_dep_jumps, jumptovars_map = jump_to_dep_specs)
102101

103102
for method in methods
104103
local jump_prob = JumpProblem(prob, method, jump, jump2; rng = rng, namedpars...)
@@ -109,8 +108,7 @@ for method in methods
109108
end
110109

111110
if doprint
112-
println("Mix of constant and mass action jumps, method = ", typeof(method),
113-
", sol[end] = ", sol[end, end])
111+
println("Mix of constant and mass action jumps, method = ", typeof(method), ", sol[end] = ", sol[end, end])
114112
end
115113
@test sol[end, end] > 200
116114
end

test/extended_jump_array.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ rng = StableRNG(123)
77
# Check that the new broadcast norm gives the same result as the old one
88
rand_array = ExtendedJumpArray{Float64, 1, Vector{Float64}, Vector{Float64}}(rand(rng, 5),
99
rand(rng, 2))
10-
old_norm = Base.FastMath.sqrt_fast(DiffEqBase.UNITLESS_ABS2(rand_array) /
11-
max(DiffEqBase.recursive_length(rand_array), 1))
10+
old_norm = Base.FastMath.sqrt_fast(DiffEqBase.UNITLESS_ABS2(rand_array) / max(DiffEqBase.recursive_length(rand_array), 1))
1211
new_norm = DiffEqBase.ODE_DEFAULT_NORM(rand_array, 0.0)
1312
@test old_norm new_norm
1413

1514
# Check for an ExtendedJumpArray where the types differ (Float64/Int64)
1615
rand_array = ExtendedJumpArray{Float64, 1, Vector{Float64}, Vector{Int64}}(rand(rng, 5),
1716
rand(rng, 1:1000,
1817
2))
19-
old_norm = Base.FastMath.sqrt_fast(DiffEqBase.UNITLESS_ABS2(rand_array) /
20-
max(DiffEqBase.recursive_length(rand_array), 1))
18+
old_norm = Base.FastMath.sqrt_fast(DiffEqBase.UNITLESS_ABS2(rand_array) / max(DiffEqBase.recursive_length(rand_array), 1))
2119
new_norm = DiffEqBase.ODE_DEFAULT_NORM(rand_array, 0.0)
2220
@test old_norm new_norm
2321

test/hawkes_test.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ let alg = Coevolve()
156156
for vr_aggregator in (VR_FRM(), VR_Direct(), VR_DirectFW())
157157
oprob = ODEProblem(f!, u0, tspan, p)
158158
jumps = hawkes_jump(u0, g, h)
159-
jprob = JumpProblem(oprob, alg, jumps...; vr_aggregator, dep_graph = g, rng,
160-
use_vrj_bounds = false)
159+
jprob = JumpProblem(oprob, alg, jumps...; vr_aggregator, dep_graph = g, rng, use_vrj_bounds = false)
161160
@test length(jprob.variable_jumps) == 1
162161
sols = Vector{ODESolution}(undef, Nsims)
163162
for n in 1:Nsims

test/spatial/hop_rates.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ for hop_rates in hop_rates_structs
121121
target_propensities[target] = sum([hop_constants[species, site][i]
122122
for species in 1:num_species])
123123
end
124-
statistical_test(hop_rates, spec_propensities, target_propensities, num_species, u,
125-
site, g, rng, rel_tol)
124+
statistical_test(hop_rates, spec_propensities, target_propensities, num_species, u, site, g, rng, rel_tol)
126125
end
127126
end
128127
test_reset(hop_rates, num_nodes)
@@ -153,8 +152,7 @@ for hop_rates in hop_rates_structs
153152
site_hop_constants[site][i]
154153
for species in 1:num_species])
155154
end
156-
statistical_test(hop_rates, spec_propensities, target_propensities, num_species, u,
157-
site, g, rng, rel_tol)
155+
statistical_test(hop_rates, spec_propensities, target_propensities, num_species, u, site, g, rng, rel_tol)
158156
end
159157
end
160158
test_reset(hop_rates, num_nodes)
@@ -177,16 +175,14 @@ hop_rates_structs = [
177175
for hop_rates in hop_rates_structs
178176
show(io, "text/plain", hop_rates)
179177
for site in 1:num_nodes
180-
spec_propensities = [species_hop_constants[species, site] *
181-
sum(site_hop_constants[site]) for species in 1:num_species]
178+
spec_propensities = [species_hop_constants[species, site] * sum(site_hop_constants[site]) for species in 1:num_species]
182179
target_propensities = Dict{Int, Float64}()
183180
for (i, target) in enumerate(JP.neighbors(g, site))
184181
target_propensities[target] = sum([species_hop_constants[species, site] *
185182
site_hop_constants[site][i]
186183
for species in 1:num_species])
187184
end
188-
statistical_test(hop_rates, spec_propensities, target_propensities, num_species, u,
189-
site, g, rng, rel_tol)
185+
statistical_test(hop_rates, spec_propensities, target_propensities, num_species, u, site, g, rng, rel_tol)
190186
end
191187
end
192188
test_reset(hop_rates, num_nodes)

0 commit comments

Comments
 (0)