Skip to content

Commit a99e52b

Browse files
committed
Switch from JuliaFormatter to Runic.jl for code formatting
- Update CI workflow to use fredrikekre/runic-action@v1 - Remove .JuliaFormatter.toml configuration - Format all source files with Runic.jl 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent d2b904b commit a99e52b

File tree

17 files changed

+486
-320
lines changed

17 files changed

+486
-320
lines changed

.JuliaFormatter.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/FormatCheck.yml

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,17 @@ name: format-check
33
on:
44
push:
55
branches:
6+
- 'master'
67
- 'main'
78
- 'release-'
89
tags: '*'
910
pull_request:
1011

1112
jobs:
12-
build:
13-
runs-on: ${{ matrix.os }}
14-
strategy:
15-
matrix:
16-
julia-version: [1]
17-
julia-arch: [x86]
18-
os: [ubuntu-latest]
13+
runic:
14+
runs-on: ubuntu-latest
1915
steps:
20-
- uses: julia-actions/setup-julia@latest
21-
with:
22-
version: ${{ matrix.julia-version }}
23-
2416
- uses: actions/checkout@v4
25-
- name: Install JuliaFormatter and format
26-
# This will use the latest version by default but you can set the version like so:
27-
#
28-
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
29-
run: |
30-
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
31-
julia -e 'using JuliaFormatter; format(".", verbose=true)'
32-
- name: Format check
33-
run: |
34-
julia -e '
35-
out = Cmd(`git diff --name-only`) |> read |> String
36-
if out == ""
37-
exit(0)
38-
else
39-
@error "Some files have not been formatted !!!"
40-
write(stdout, out)
41-
exit(1)
42-
end'
17+
- uses: fredrikekre/runic-action@v1
18+
with:
19+
version: '1'

docs/make.jl

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,33 @@ using Plots
77
cp("./docs/Manifest.toml", "./docs/src/assets/Manifest.toml", force = true)
88
cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)
99

10-
mathengine = MathJax3(Dict(:loader => Dict("load" => ["[tex]/require", "[tex]/mathtools"]),
11-
:tex => Dict("inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
12-
"packages" => [
13-
"base",
14-
"ams",
15-
"autoload",
16-
"mathtools",
17-
"require"
18-
])))
10+
mathengine = MathJax3(
11+
Dict(
12+
:loader => Dict("load" => ["[tex]/require", "[tex]/mathtools"]),
13+
:tex => Dict(
14+
"inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
15+
"packages" => [
16+
"base",
17+
"ams",
18+
"autoload",
19+
"mathtools",
20+
"require",
21+
]
22+
)
23+
)
24+
)
1925

20-
makedocs(sitename = "EasyModelAnalysis.jl",
26+
makedocs(
27+
sitename = "EasyModelAnalysis.jl",
2128
authors = "Chris Rackauckas",
2229
modules = Module[EasyModelAnalysis],
2330
clean = true, doctest = false, linkcheck = true,
2431
warnonly = [:missing_docs, :example_block],
25-
format = Documenter.HTML(assets = ["assets/favicon.ico"],
32+
format = Documenter.HTML(
33+
assets = ["assets/favicon.ico"],
2634
canonical = "https://docs.sciml.ai/EasyModelAnalysis/stable/",
27-
mathengine = mathengine),
35+
mathengine = mathengine
36+
),
2837
pages = [
2938
"EasyModelAnalysis.jl: Quick and Easy Queries to Simulation Results" => "index.md",
3039
"Getting Started with EasyModelAnalysis" => "getting_started.md",
@@ -33,27 +42,28 @@ makedocs(sitename = "EasyModelAnalysis.jl",
3342
"tutorials/datafitting.md",
3443
"tutorials/threshold_interventions.md",
3544
"tutorials/probabilistic_thresholds.md",
36-
"tutorials/ensemble_modeling.md"
45+
"tutorials/ensemble_modeling.md",
3746
],
3847
"Examples" => [
3948
"examples/petri.md",
4049
"examples/ASIR.md",
4150
"examples/SEIRHD.md",
42-
"examples/Carcione2020.md"
51+
"examples/Carcione2020.md",
4352
],
4453
"Scenarios" => [
4554
"scenarios/scenario1.md",
4655
"scenarios/scenario2.md",
4756
"scenarios/scenario3.md",
4857
"scenarios/scenario4.md",
49-
"scenarios/scenario5.md"
58+
"scenarios/scenario5.md",
5059
],
5160
"API" => [
5261
"api/basic_queries.md",
5362
"api/data_fitting_calibration.md",
5463
"api/sensitivity_analysis.md",
55-
"api/threshold_interventions.md"
56-
]
57-
])
64+
"api/threshold_interventions.md",
65+
],
66+
]
67+
)
5868

5969
deploydocs(repo = "github.com/SciML/EasyModelAnalysis.jl")

src/EasyModelAnalysis.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export get_sensitivity, create_sensitivity_plot, get_sensitivity_of_maximum
2626
export stop_at_threshold, get_threshold
2727
export model_forecast_score
2828
export optimal_threshold_intervention, prob_violating_threshold,
29-
optimal_parameter_intervention_for_threshold, optimal_parameter_threshold,
30-
optimal_parameter_intervention_for_reach
29+
optimal_parameter_intervention_for_threshold, optimal_parameter_threshold,
30+
optimal_parameter_intervention_for_reach
3131
export bayesian_ensemble, ensemble_weights
3232

3333
end

src/basics.jl

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function get_timeseries(prob, sym, t)
77
@assert t[1] >= prob.tspan[1]
88
prob = remake(prob, tspan = (prob.tspan[1], min(prob.tspan[2], t[end])))
99
sol = solve(prob, saveat = t)
10-
sol[sym]
10+
return sol[sym]
1111
end
1212

1313
"""
@@ -24,11 +24,13 @@ function get_min_t(prob, sym)
2424
sol = solve(prob)
2525
end
2626
f(t, _) = sol(t[1]; idxs = sym)
27-
oprob = OptimizationProblem(f, [(prob.tspan[2] - prob.tspan[1]) / 2],
27+
oprob = OptimizationProblem(
28+
f, [(prob.tspan[2] - prob.tspan[1]) / 2],
2829
lb = [prob.tspan[1]],
29-
ub = [prob.tspan[end]])
30+
ub = [prob.tspan[end]]
31+
)
3032
res = solve(oprob, BBO_adaptive_de_rand_1_bin_radiuslimited(), maxiters = 10000)
31-
res.u[1], f(res.u[1], nothing)
33+
return res.u[1], f(res.u[1], nothing)
3234
end
3335

3436
"""
@@ -45,11 +47,13 @@ function get_max_t(prob, sym)
4547
sol = solve(prob)
4648
end
4749
f(t, _) = -sol(t[1]; idxs = sym)
48-
oprob = OptimizationProblem(f, [(prob.tspan[2] - prob.tspan[1]) / 2],
50+
oprob = OptimizationProblem(
51+
f, [(prob.tspan[2] - prob.tspan[1]) / 2],
4952
lb = [prob.tspan[1]],
50-
ub = [prob.tspan[end]])
53+
ub = [prob.tspan[end]]
54+
)
5155
res = solve(oprob, BBO_adaptive_de_rand_1_bin_radiuslimited(), maxiters = 10000)
52-
res.u[1], -f(res.u[1], nothing)
56+
return res.u[1], -f(res.u[1], nothing)
5357
end
5458

5559
"""
@@ -63,7 +67,7 @@ function plot_extrema(prob, sym)
6367
sol = solve(prob)
6468
plot(sol, idxs = sym)
6569
scatter!([xmin], [xminval])
66-
scatter!([xmax], [xmaxval])
70+
return scatter!([xmax], [xmaxval])
6771
end
6872

6973
"""
@@ -79,7 +83,7 @@ function phaseplot_extrema(prob, sym, plotsyms)
7983
xmax, xmaxval = get_max_t(prob, sym)
8084
plot(sol, idxs = plotsyms)
8185
scatter!([[sol(xmin; idxs = x)] for x in plotsyms]...)
82-
scatter!([[sol(xmax; idxs = x)] for x in plotsyms]...)
86+
return scatter!([[sol(xmax; idxs = x)] for x in plotsyms]...)
8387
end
8488

8589
"""
@@ -94,12 +98,14 @@ function get_uncertainty_forecast(prob, sym, t, uncertainp, samples)
9498
@assert t[1] >= prob.tspan[1]
9599
function prob_func(prob, i, reset)
96100
ps = getindex.(uncertainp, 1) .=> rand.(getindex.(uncertainp, 2))
97-
prob = remake(prob, tspan = (prob.tspan[1], min(prob.tspan[2], t[end])),
98-
p = ps)
101+
return prob = remake(
102+
prob, tspan = (prob.tspan[1], min(prob.tspan[2], t[end])),
103+
p = ps
104+
)
99105
end
100106
eprob = EnsembleProblem(prob, prob_func = prob_func)
101107
esol = solve(eprob, nothing, EnsembleSerial(), saveat = t, trajectories = samples)
102-
Array.(reduce.(hcat, [esol[i][sym] for i in 1:samples]))
108+
return Array.(reduce.(hcat, [esol[i][sym] for i in 1:samples]))
103109
end
104110

105111
"""
@@ -112,46 +118,58 @@ distribution. Samples is the number of trajectories to run.
112118
113119
Returns a tuple of arrays for the quantiles `quants` which defaults to the 95% confidence intervals.
114120
"""
115-
function get_uncertainty_forecast_quantiles(prob, sym, t, uncertainp, samples,
116-
quants = (0.05, 0.95))
121+
function get_uncertainty_forecast_quantiles(
122+
prob, sym, t, uncertainp, samples,
123+
quants = (0.05, 0.95)
124+
)
117125
@assert t[1] >= prob.tspan[1]
118126
function prob_func(prob, i, reset)
119127
ps = getindex.(uncertainp, 1) .=> rand.(getindex.(uncertainp, 2))
120-
prob = remake(prob, tspan = (prob.tspan[1], min(prob.tspan[2], t[end])),
121-
p = ps)
128+
return prob = remake(
129+
prob, tspan = (prob.tspan[1], min(prob.tspan[2], t[end])),
130+
p = ps
131+
)
122132
end
123133
eprob = EnsembleProblem(prob, prob_func = prob_func)
124134

125135
indexof(sym, syms) = indexin(Symbol.(sym), Symbol.(syms))
126136
idx = indexof(sym, states(prob.f.sys))
127137

128-
esol = solve(eprob, nothing, EnsembleSerial(), saveat = t, trajectories = samples,
129-
save_idxs = idx)
130-
[Array(reduce(hcat, SciMLBase.EnsembleAnalysis.timeseries_steps_quantile(esol, q).u)')
131-
for q in quants]
138+
esol = solve(
139+
eprob, nothing, EnsembleSerial(), saveat = t, trajectories = samples,
140+
save_idxs = idx
141+
)
142+
return [
143+
Array(reduce(hcat, SciMLBase.EnsembleAnalysis.timeseries_steps_quantile(esol, q).u)')
144+
for q in quants
145+
]
132146
end
133147

134148
"""
135149
plot_uncertainty_forecast(prob, sym, t, uncertainp, samples)
136150
"""
137-
function plot_uncertainty_forecast(prob, sym, t, uncertainp, samples;
151+
function plot_uncertainty_forecast(
152+
prob, sym, t, uncertainp, samples;
138153
label = reshape(string.(Symbol.(sym)), 1, length(sym)),
139-
kwargs...)
154+
kwargs...
155+
)
140156
esol = get_uncertainty_forecast(prob, sym, t, uncertainp, samples)
141157
p = plot(Array(esol[1]'), idxs = sym; label = label, kwargs...)
142158
for i in 2:samples
143159
plot!(p, Array(esol[i]'), idxs = sym; label = false, kwargs...)
144160
end
145-
display(p)
161+
return display(p)
146162
end
147163

148164
"""
149165
plot_uncertainty_forecast_quantiles(prob, sym, t, uncertainp, samples, quants = (0.05, 0.95))
150166
"""
151-
function plot_uncertainty_forecast_quantiles(prob, sym, t, uncertainp, samples,
167+
function plot_uncertainty_forecast_quantiles(
168+
prob, sym, t, uncertainp, samples,
152169
quants = (0.05, 0.95); label = false,
153-
kwargs...)
170+
kwargs...
171+
)
154172
qs = get_uncertainty_forecast_quantiles(prob, sym, t, uncertainp, samples, quants)
155173
plot(t, qs[1]; label = label, kwargs...)
156-
plot!(t, qs[2]; label = false, kwargs...)
174+
return plot!(t, qs[2]; label = false, kwargs...)
157175
end

0 commit comments

Comments
 (0)