Skip to content

Commit d2d4286

Browse files
Merge pull request #579 from ChrisRackauckas-Claude/runic-formatting
Switch from JuliaFormatter to Runic.jl for code formatting
2 parents e10e728 + 101a719 commit d2d4286

83 files changed

Lines changed: 1473 additions & 893 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.JuliaFormatter.toml

Lines changed: 0 additions & 4 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-check.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: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using Pkg
55

66
function dev_subpkg(subpkg)
77
subpkg_path = abspath(joinpath(dirname(@__FILE__), "..", "lib", subpkg))
8-
Pkg.develop(PackageSpec(path = subpkg_path))
8+
return Pkg.develop(PackageSpec(path = subpkg_path))
99
end
1010

1111
dev_subpkg("DataDrivenDMD")
@@ -50,25 +50,34 @@ function create_tutorials(dirname, targetdir, excludes = [])
5050
mdpost(str) = replace(str, "@__CODE__" => code)
5151
Literate.markdown(ipath, targetdir)
5252
Literate.markdown(ipath, targetdir, execute = false, postprocess = mdpost)
53-
push!(tutorials,
54-
relpath(joinpath(targetdir, fname * ".md"), joinpath(@__DIR__, "src")))
53+
push!(
54+
tutorials,
55+
relpath(joinpath(targetdir, fname * ".md"), joinpath(@__DIR__, "src"))
56+
)
5557
end
5658
end
5759
return tutorials
5860
end
5961

60-
koopman_tutorial = create_tutorials(joinpath(@__DIR__, "src/libs/datadrivendmd/"),
61-
joinpath(@__DIR__, "src/libs/datadrivendmd/examples"))
62-
sparse_tutorial = create_tutorials(joinpath(@__DIR__, "src/libs/datadrivensparse/"),
63-
joinpath(@__DIR__, "src/libs/datadrivensparse/examples"))
64-
sr_tutorial = create_tutorials(joinpath(@__DIR__, "src/libs/datadrivensr/"),
65-
joinpath(@__DIR__, "src/libs/datadrivensr/examples"))
62+
koopman_tutorial = create_tutorials(
63+
joinpath(@__DIR__, "src/libs/datadrivendmd/"),
64+
joinpath(@__DIR__, "src/libs/datadrivendmd/examples")
65+
)
66+
sparse_tutorial = create_tutorials(
67+
joinpath(@__DIR__, "src/libs/datadrivensparse/"),
68+
joinpath(@__DIR__, "src/libs/datadrivensparse/examples")
69+
)
70+
sr_tutorial = create_tutorials(
71+
joinpath(@__DIR__, "src/libs/datadrivensr/"),
72+
joinpath(@__DIR__, "src/libs/datadrivensr/examples")
73+
)
6674

6775
# Must be after tutorials is created
6876
include("pages.jl")
6977

7078
# Create the docs
71-
makedocs(sitename = "DataDrivenDiffEq.jl",
79+
makedocs(
80+
sitename = "DataDrivenDiffEq.jl",
7281
authors = "Julius Martensen, Christopher Rackauckas, et al.",
7382
modules = [DataDrivenDiffEq, DataDrivenDMD, DataDrivenSparse, DataDrivenSR],
7483
clean = true, doctest = false, linkcheck = true,
@@ -77,11 +86,16 @@ makedocs(sitename = "DataDrivenDiffEq.jl",
7786
"http://cwrowley.princeton.edu/papers/Hemati-2017a.pdf",
7887
"https://royalsocietypublishing.org/doi/10.1098/rspa.2020.0279",
7988
"https://www.pnas.org/doi/10.1073/pnas.1517384113",
80-
"https://link.springer.com/article/10.1007/s00332-015-9258-5"
89+
"https://link.springer.com/article/10.1007/s00332-015-9258-5",
8190
],
82-
format = Documenter.HTML(assets = ["assets/favicon.ico"],
83-
canonical = "https://docs.sciml.ai/DataDrivenDiffEq/stable/"),
84-
pages = pages)
91+
format = Documenter.HTML(
92+
assets = ["assets/favicon.ico"],
93+
canonical = "https://docs.sciml.ai/DataDrivenDiffEq/stable/"
94+
),
95+
pages = pages
96+
)
8597

86-
deploydocs(repo = "github.com/SciML/DataDrivenDiffEq.jl.git";
87-
push_preview = true)
98+
deploydocs(
99+
repo = "github.com/SciML/DataDrivenDiffEq.jl.git";
100+
push_preview = true
101+
)

docs/pages.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ pages = [
55
"Basis" => "basis.md",
66
"Solutions" => "solutions.md",
77
"Utilities" => "utils.md",
8-
"DataDrivenDMD" => ["Background" => "libs/datadrivendmd/koopman.md",
9-
"Examples" => koopman_tutorial
8+
"DataDrivenDMD" => [
9+
"Background" => "libs/datadrivendmd/koopman.md",
10+
"Examples" => koopman_tutorial,
1011
],
11-
"DataDrivenSparse" => ["Background" => "libs/datadrivensparse/sparse_regression.md",
12-
"Examples" => sparse_tutorial
12+
"DataDrivenSparse" => [
13+
"Background" => "libs/datadrivensparse/sparse_regression.md",
14+
"Examples" => sparse_tutorial,
1315
],
14-
"DataDrivenSR" => ["Background" => "libs/datadrivensr/symbolic_regression.md",
15-
"Examples" => sr_tutorial
16+
"DataDrivenSR" => [
17+
"Background" => "libs/datadrivensr/symbolic_regression.md",
18+
"Examples" => sr_tutorial,
1619
],
17-
"Citing" => "citations.md"
20+
"Citing" => "citations.md",
1821
]

docs/src/libs/datadrivendmd/example_01.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ get_basis(res)
4747
#md # ```
4848

4949
## Test the result #src
50-
@test rss(res) <= 1e-3 #src
50+
@test rss(res) <= 1.0e-3 #src
5151
@test r2(res) >= 0.99 #src
5252
@test dof(res) == 3 #src

docs/src/libs/datadrivendmd/example_04.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using DataDrivenDMD
1010

1111
function slow_manifold(du, u, p, t)
1212
du[1] = p[1] * u[1]
13-
du[2] = p[2] * (u[2] - u[1]^2)
13+
return du[2] = p[2] * (u[2] - u[1]^2)
1414
end
1515

1616
u0 = [3.0; -2.0]

docs/src/libs/datadrivendmd/example_05.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ end
4141
# System dynamics
4242
function controlled_system!(du, u, p, t)
4343
ctrl = control_signal(t)
44-
du .= A_true * u .+ B_true .* ctrl
44+
return du .= A_true * u .+ B_true .* ctrl
4545
end
4646

4747
# Generate "experimental" data

docs/src/libs/datadrivensparse/example_01.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# # [Getting Started](@id getting_started)
22
#
3-
# The workflow for [DataDrivenDiffEq.jl](https://github.com/SciML/DataDrivenDiffEq.jl) is similar to other [SciML](https://sciml.ai/) packages.
3+
# The workflow for [DataDrivenDiffEq.jl](https://github.com/SciML/DataDrivenDiffEq.jl) is similar to other [SciML](https://sciml.ai/) packages.
44
# You start by defining a [`DataDrivenProblem`](@ref) and then dispatch on the [`solve`](@ref solve) command to return a [`DataDrivenSolution`](@ref).
55

66
# Here is an outline of the required elements and choices:
@@ -13,7 +13,7 @@ using ModelingToolkit
1313
using LinearAlgebra
1414
using DataDrivenSparse
1515

16-
# Generate a test problem
16+
# Generate a test problem
1717

1818
f(u) = u .^ 2 .+ 2.0u .- 1.0
1919
X = randn(1, 100);

docs/src/libs/datadrivensparse/example_02.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ ts = sol.t;
3838
# Using a [collocation method](@ref collocation), it automatically provides the derivative and smoothes the trajectory. Control signals can be passed
3939
# in as a function `(u,p,t)->control` or an array of measurements.
4040

41-
prob = ContinuousDataDrivenProblem(X, ts, GaussianKernel(),
41+
prob = ContinuousDataDrivenProblem(
42+
X, ts, GaussianKernel(),
4243
U = (u, p, t) -> [exp(-((t - 5.0) / 5.0)^2)],
43-
p = ones(2))
44+
p = ones(2)
45+
)
4446

4547
#md plot(prob, size = (600,600))
4648

@@ -65,8 +67,10 @@ println(basis) # hide
6567
sampler = DataProcessing(split = 0.8, shuffle = true, batchsize = 30, rng = rng)
6668
λs = exp10.(-10:0.1:0)
6769
opt = STLSQ(λs)
68-
res = solve(prob, basis, opt,
69-
options = DataDrivenCommonOptions(data_processing = sampler, digits = 1))
70+
res = solve(
71+
prob, basis, opt,
72+
options = DataDrivenCommonOptions(data_processing = sampler, digits = 1)
73+
)
7074
#src println(res) #hide
7175

7276
# !!! info

docs/src/libs/datadrivensparse/example_03.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ using DataDrivenSparse
1313
using Test #src
1414

1515
function michaelis_menten(u, p, t)
16-
[0.6 - 1.5u[1] / (0.3 + u[1])]
16+
return [0.6 - 1.5u[1] / (0.3 + u[1])]
1717
end
1818

1919
u0 = [0.5]
@@ -23,10 +23,14 @@ ode_problem = ODEProblem(michaelis_menten, u0, (0.0, 4.0));
2323
# Since we have multiple trajectories at hand, we define a [`DataDrivenDataset`](@ref), which collects multiple problems but handles them as a unit
2424
# for the processing.
2525

26-
prob = DataDrivenDataset(map(1:2) do i
27-
solve(remake(ode_problem, u0 = i * u0),
28-
Tsit5(), saveat = 0.1, tspan = (0.0, 4.0))
29-
end...)
26+
prob = DataDrivenDataset(
27+
map(1:2) do i
28+
solve(
29+
remake(ode_problem, u0 = i * u0),
30+
Tsit5(), saveat = 0.1, tspan = (0.0, 4.0)
31+
)
32+
end...
33+
)
3034

3135
#md plot(prob)
3236

@@ -44,7 +48,7 @@ basis = Basis([h; h .* (D(u[1]))], u, implicits = D.(u), iv = t)
4448
# Next, we define the [`ImplicitOptimizer`](@ref) and `solve` the problem. It wraps a standard optimizer, by default [`STLSQ`](@ref), and performs
4549
# implicit sparse regression upon the selected basis.
4650

47-
opt = ImplicitOptimizer(1e-1:1e-1:5e-1)
51+
opt = ImplicitOptimizer(1.0e-1:1.0e-1:5.0e-1)
4852
res = solve(prob, basis, opt)
4953
#md println(res) #hide
5054

0 commit comments

Comments
 (0)