Skip to content

Commit b3be182

Browse files
committed
Use JuliaFormatter with SciML style
1 parent 105f30a commit b3be182

19 files changed

+1735
-1568
lines changed

.JuliaFormatter.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style = "sciml"

.github/workflows/FormatCheck.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: format-check
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'release-'
8+
tags: '*'
9+
pull_request:
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: julia-actions/setup-julia@v1
17+
with:
18+
version: 1
19+
- name: Install JuliaFormatter
20+
run: |
21+
using Pkg
22+
name = "JuliaFormatter"
23+
uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
24+
Pkg.add(; name, uuid)
25+
shell: julia --color=yes {0}
26+
- name: Format Julia code
27+
run: |
28+
using JuliaFormatter
29+
format("."; verbose = true)
30+
shell: julia --color=yes {0}
31+
- name: Format check
32+
run: |
33+
out = Cmd(`git diff --name-only`) |> read |> String
34+
if out == ""
35+
exit(0)
36+
else
37+
@error "Some files have not been formatted !!!"
38+
write(stdout, out)
39+
exit(1)
40+
end
41+
shell: julia --color=yes {0}

src/DiffEqProblemLibrary.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,41 @@ module DiffEqProblemLibrary
33
module ODEProblemLibrary
44
using Latexify
55
function importodeproblems()
6-
@isdefined(prob_ode_linear) ||
7-
include(joinpath(@__DIR__, "ode/ode_premade_problems.jl"));
8-
nothing
6+
@isdefined(prob_ode_linear) ||
7+
include(joinpath(@__DIR__, "ode/ode_premade_problems.jl"))
8+
nothing
99
end
1010
end # module
1111

1212
module DAEProblemLibrary
1313
function importdaeproblems()
14-
@isdefined(prob_dae_resrob) ||
15-
include(joinpath(@__DIR__, "dae_premade_problems.jl"));
16-
nothing
14+
@isdefined(prob_dae_resrob) ||
15+
include(joinpath(@__DIR__, "dae_premade_problems.jl"))
16+
nothing
1717
end
1818
end # module
1919

2020
module DDEProblemLibrary
2121
function importddeproblems()
22-
@isdefined(prob_dde_1delay) ||
23-
include(joinpath(@__DIR__, "dde/dde_premade_problems.jl"));
24-
nothing
22+
@isdefined(prob_dde_1delay) ||
23+
include(joinpath(@__DIR__, "dde/dde_premade_problems.jl"))
24+
nothing
2525
end
2626
end # module
2727

2828
module SDEProblemLibrary
2929
function importsdeproblems()
30-
@isdefined(prob_sde_wave) ||
31-
include(joinpath(@__DIR__, "sde_premade_problems.jl"));
32-
nothing
30+
@isdefined(prob_sde_wave) ||
31+
include(joinpath(@__DIR__, "sde_premade_problems.jl"))
32+
nothing
3333
end
3434
end # module
3535

3636
module JumpProblemLibrary
3737
function importjumpproblems()
38-
@isdefined(prob_jump_dnarepressor) ||
39-
include(joinpath(@__DIR__, "jump_premade_problems.jl"));
40-
nothing
38+
@isdefined(prob_jump_dnarepressor) ||
39+
include(joinpath(@__DIR__, "jump_premade_problems.jl"))
40+
nothing
4141
end
4242
end # module
4343

src/dae_premade_problems.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export prob_dae_resrob
66
### DAE Problems
77

88
f = function (r, yp, y, p, tres)
9-
r[1] = -0.04*y[1] + 1.0e4*y[2]*y[3]
10-
r[2] = -r[1] - 3.0e7*y[2]*y[2] - yp[2]
11-
r[1] -= yp[1]
12-
r[3] = y[1] + y[2] + y[3] - 1.0
9+
r[1] = -0.04 * y[1] + 1.0e4 * y[2] * y[3]
10+
r[2] = -r[1] - 3.0e7 * y[2] * y[2] - yp[2]
11+
r[1] -= yp[1]
12+
r[3] = y[1] + y[2] + y[3] - 1.0
1313
end
1414
u0 = [1.0, 0, 0]
1515
du0 = [-0.04, 0.04, 0.0]
@@ -30,4 +30,4 @@ where ``k₁=0.04``, ``k₂=3\times10^7``, ``k₃=10^4``. For details, see:
3030
Hairer Norsett Wanner Solving Ordinary Differential Equations I - Nonstiff Problems Page 129
3131
Usually solved on ``[0,1e11]``
3232
"""
33-
prob_dae_resrob = DAEProblem(f,du0,u0,(0.0,100000.0))
33+
prob_dae_resrob = DAEProblem(f, du0, u0, (0.0, 100000.0))

0 commit comments

Comments
 (0)