Skip to content

Commit bfecb08

Browse files
Merge pull request #1006 from ChrisRackauckas-Claude/runic-formatting
Switch from JuliaFormatter to Runic.jl for code formatting
2 parents 0c48e10 + e7b5e7e commit bfecb08

38 files changed

+3184
-2089
lines changed

.JuliaFormatter.toml

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

.github/workflows/FormatCheck.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
name: "Format Check"
1+
name: format-check
22

33
on:
44
push:
55
branches:
66
- 'master'
7+
- 'main'
8+
- 'release-'
79
tags: '*'
810
pull_request:
911

1012
jobs:
11-
format-check:
12-
name: "Format Check"
13-
uses: "SciML/.github/.github/workflows/format-suggestions-on-pr.yml@v1"
13+
runic:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: fredrikekre/runic-action@v1
18+
with:
19+
version: '1'

docs/make.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ using Plots
99

1010
include("pages.jl")
1111

12-
makedocs(sitename = "NeuralPDE.jl",
12+
makedocs(
13+
sitename = "NeuralPDE.jl",
1314
authors = "#",
1415
modules = [NeuralPDE],
1516
clean = true, doctest = false, linkcheck = true,
1617
warnonly = [:missing_docs],
17-
format = Documenter.HTML(assets = ["assets/favicon.ico"],
18-
canonical = "https://docs.sciml.ai/NeuralPDE/stable/"),
19-
pages = pages)
18+
format = Documenter.HTML(
19+
assets = ["assets/favicon.ico"],
20+
canonical = "https://docs.sciml.ai/NeuralPDE/stable/"
21+
),
22+
pages = pages
23+
)
2024

2125
deploydocs(repo = "github.com/SciML/NeuralPDE.jl.git"; push_preview = true)

docs/pages.jl

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
pages = ["index.md",
2-
"ODE PINN Tutorials" => Any["Introduction to NeuralPDE for ODEs" => "tutorials/ode.md",
1+
pages = [
2+
"index.md",
3+
"ODE PINN Tutorials" => Any[
4+
"Introduction to NeuralPDE for ODEs" => "tutorials/ode.md",
35
"Bayesian PINNs for Coupled ODEs" => "tutorials/Lotka_Volterra_BPINNs.md",
46
"PINNs DAEs" => "tutorials/dae.md",
57
"Parameter Estimation with PINNs for ODEs" => "tutorials/ode_parameter_estimation.md",
68
"Improved PINNs for Inverse problems in ODEs" => "tutorials/data_collocation_Inverse.md",
79
"Physics informed Neural Operator ODEs" => "tutorials/pino_ode.md",
8-
"Deep Galerkin Method" => "tutorials/dgm.md" #"examples/nnrode_example.md", # currently incorrect
10+
"Deep Galerkin Method" => "tutorials/dgm.md", #"examples/nnrode_example.md", # currently incorrect
911
],
1012
"PDE PINN Tutorials" => Any[
1113
"Introduction to NeuralPDE for PDEs" => "tutorials/pdesystem.md",
@@ -17,23 +19,28 @@ pages = ["index.md",
1719
"Optimising Parameters (Solving Inverse Problems)" => "tutorials/param_estim.md",
1820
"Solving Integro Differential Equations" => "tutorials/integro_diff.md",
1921
"Transfer Learning with Neural Adapter" => "tutorials/neural_adapter.md",
20-
"The Derivative Neural Network Approximation" => "tutorials/derivative_neural_network.md"],
21-
"Extended Examples" => Any["examples/wave.md",
22+
"The Derivative Neural Network Approximation" => "tutorials/derivative_neural_network.md",
23+
],
24+
"Extended Examples" => Any[
25+
"examples/wave.md",
2226
"examples/3rd.md",
2327
"examples/ks.md",
2428
"examples/heterogeneous.md",
2529
"examples/linear_parabolic.md",
2630
"examples/nonlinear_elliptic.md",
2731
"examples/nonlinear_hyperbolic.md",
28-
"examples/complex.md"],
29-
"Manual" => Any["manual/ode.md",
32+
"examples/complex.md",
33+
],
34+
"Manual" => Any[
35+
"manual/ode.md",
3036
"manual/dae.md",
3137
"manual/pinns.md",
3238
"manual/bpinns.md",
3339
"manual/training_strategies.md",
3440
"manual/adaptive_losses.md",
3541
"manual/logging.md",
3642
"manual/neural_adapters.md",
37-
"manual/pino_ode.md"],
38-
"Developer Documentation" => Any["developer/debugging.md"]
43+
"manual/pino_ode.md",
44+
],
45+
"Developer Documentation" => Any["developer/debugging.md"],
3946
]

ext/NeuralPDETensorBoardLoggerExt.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ module NeuralPDETensorBoardLoggerExt
33
using NeuralPDE: NeuralPDE
44
using TensorBoardLogger: TBLogger, log_value
55

6-
function NeuralPDE.logvector(logger::TBLogger, vector::AbstractVector{<:Real},
7-
name::AbstractString, step::Integer)
8-
foreach(enumerate(vector)) do (j, v)
6+
function NeuralPDE.logvector(
7+
logger::TBLogger, vector::AbstractVector{<:Real},
8+
name::AbstractString, step::Integer
9+
)
10+
return foreach(enumerate(vector)) do (j, v)
911
log_value(logger, "$(name)/$(j)", v; step)
1012
end
1113
end
1214

13-
function NeuralPDE.logscalar(logger::TBLogger, scalar::Real, name::AbstractString,
14-
step::Integer)
15+
function NeuralPDE.logscalar(
16+
logger::TBLogger, scalar::Real, name::AbstractString,
17+
step::Integer
18+
)
1519
log_value(logger, "$(name)", scalar; step)
1620
return nothing
1721
end

src/BPINN_ode.jl

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,25 @@ Kevin Linka, Amelie Schäfer, Xuhui Meng, Zongren Zou, George Em Karniadakis, El
101101
verbose::Bool
102102
end
103103

104-
function BNNODE(chain, kernel = HMC; strategy = nothing, draw_samples = 1000,
104+
function BNNODE(
105+
chain, kernel = HMC; strategy = nothing, draw_samples = 1000,
105106
priorsNNw = (0.0, 2.0), param = nothing, l2std = [0.05], phystd = [0.05],
106107
phynewstd = (ode_params) -> [0.05], dataset = [], physdt = 1 / 20.0,
107108
MCMCkwargs = (n_leapfrog = 30,), nchains = 1, init_params = nothing,
108-
Adaptorkwargs = (Adaptor = StanHMCAdaptor,
109-
Metric = DiagEuclideanMetric, targetacceptancerate = 0.8),
109+
Adaptorkwargs = (
110+
Adaptor = StanHMCAdaptor,
111+
Metric = DiagEuclideanMetric, targetacceptancerate = 0.8,
112+
),
110113
Integratorkwargs = (Integrator = Leapfrog,),
111114
numensemble = floor(Int, draw_samples / 3),
112-
estim_collocate = false, autodiff = false, progress = false, verbose = false)
115+
estim_collocate = false, autodiff = false, progress = false, verbose = false
116+
)
113117
chain isa AbstractLuxLayer || (chain = FromFluxAdaptor()(chain))
114-
return BNNODE(chain, kernel, strategy, draw_samples, priorsNNw, param, l2std, phystd,
118+
return BNNODE(
119+
chain, kernel, strategy, draw_samples, priorsNNw, param, l2std, phystd,
115120
phynewstd, dataset, physdt, MCMCkwargs, nchains, init_params, Adaptorkwargs,
116-
Integratorkwargs, numensemble, estim_collocate, autodiff, progress, verbose)
121+
Integratorkwargs, numensemble, estim_collocate, autodiff, progress, verbose
122+
)
117123
end
118124

119125
"""
@@ -155,33 +161,38 @@ contains fields related to that).
155161
timepoints
156162
end
157163

158-
function SciMLBase.__solve(prob::SciMLBase.ODEProblem, alg::BNNODE, args...; dt = nothing,
164+
function SciMLBase.__solve(
165+
prob::SciMLBase.ODEProblem, alg::BNNODE, args...; dt = nothing,
159166
timeseries_errors = true, save_everystep = true, adaptive = false,
160167
abstol = 1.0f-6, reltol = 1.0f-3, verbose = false, saveat = 1 / 50.0,
161-
maxiters = nothing)
168+
maxiters = nothing
169+
)
162170
(; chain, param, strategy, draw_samples, numensemble, verbose) = alg
163171

164172
# ahmc_bayesian_pinn_ode needs param=[] for easier vcat operation for full vector of parameters
165173
param = param === nothing ? [] : param
166174
strategy = strategy === nothing ? GridTraining : strategy
167175

168-
@assert alg.draw_samples0 "Number of samples to be drawn has to be >=0."
176+
@assert alg.draw_samples 0 "Number of samples to be drawn has to be >=0."
169177

170178
mcmcchain, samples,
171-
statistics = ahmc_bayesian_pinn_ode(
179+
statistics = ahmc_bayesian_pinn_ode(
172180
prob, chain; strategy, alg.dataset, alg.draw_samples, alg.init_params,
173181
alg.physdt, alg.l2std, alg.phystd, alg.phynewstd,
174182
alg.priorsNNw, param, alg.nchains, alg.autodiff,
175183
Kernel = alg.kernel, alg.Adaptorkwargs, alg.Integratorkwargs,
176-
alg.MCMCkwargs, alg.progress, alg.verbose, alg.estim_collocate)
184+
alg.MCMCkwargs, alg.progress, alg.verbose, alg.estim_collocate
185+
)
177186

178187
fullsolution = BPINNstats(mcmcchain, samples, statistics)
179188
ninv = length(param)
180189
t = collect(eltype(saveat), prob.tspan[1]:saveat:prob.tspan[2])
181190

182191
θinit, st = LuxCore.setup(Random.default_rng(), chain)
183-
θ = [vector_to_parameters(samples[i][1:(end - ninv)], θinit)
184-
for i in (draw_samples - numensemble):draw_samples]
192+
θ = [
193+
vector_to_parameters(samples[i][1:(end - ninv)], θinit)
194+
for i in (draw_samples - numensemble):draw_samples
195+
]
185196

186197
luxar = [chain(t', θ[i], st)[1] for i in 1:numensemble]
187198
# only need for size
@@ -205,27 +216,31 @@ function SciMLBase.__solve(prob::SciMLBase.ODEProblem, alg::BNNODE, args...; dt
205216
for r in 1:numoutput
206217
ensem_r = hcat(output_matrices[r]...)'
207218
ensemblecurve_r = prob.u0[r] .+
208-
[Particles(ensem_r[:, i]) for i in 1:length(t)] .*
209-
(t .- prob.tspan[1])
219+
[Particles(ensem_r[:, i]) for i in 1:length(t)] .*
220+
(t .- prob.tspan[1])
210221
push!(ensemblecurves, ensemblecurve_r)
211222
end
212223

213224
else
214225
ensemblecurve = prob.u0 .+
215-
[Particles(reduce(vcat, luxar)[:, i]) for i in 1:length(t)] .*
216-
(t .- prob.tspan[1])
226+
[Particles(reduce(vcat, luxar)[:, i]) for i in 1:length(t)] .*
227+
(t .- prob.tspan[1])
217228
push!(ensemblecurves, ensemblecurve)
218229
end
219230

220231
nnparams = length(θinit)
221-
estimnnparams = [Particles(reduce(hcat, samples[(end - numensemble):end])[i, :])
222-
for i in 1:nnparams]
232+
estimnnparams = [
233+
Particles(reduce(hcat, samples[(end - numensemble):end])[i, :])
234+
for i in 1:nnparams
235+
]
223236

224237
if ninv == 0
225238
estimated_params = [nothing]
226239
else
227-
estimated_params = [Particles(reduce(hcat, samples[(end - numensemble):end])[i, :])
228-
for i in (nnparams + 1):(nnparams + ninv)]
240+
estimated_params = [
241+
Particles(reduce(hcat, samples[(end - numensemble):end])[i, :])
242+
for i in (nnparams + 1):(nnparams + ninv)
243+
]
229244
end
230245

231246
return BPINNsolution(fullsolution, ensemblecurves, estimnnparams, estimated_params, t)

0 commit comments

Comments
 (0)