Skip to content

Commit 759b3b8

Browse files
Merge pull request #53 from SciML/format
format SciML Style
2 parents 7f97801 + 7e1ed77 commit 759b3b8

File tree

14 files changed

+1129
-893
lines changed

14 files changed

+1129
-893
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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
julia-version: [1]
17+
julia-arch: [x86]
18+
os: [ubuntu-latest]
19+
steps:
20+
- uses: julia-actions/setup-julia@latest
21+
with:
22+
version: ${{ matrix.julia-version }}
23+
24+
- uses: actions/checkout@v1
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'

src/StochasticDelayDiffEq.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ module StochasticDelayDiffEq
66
# using DifferentialEquations
77
using Reexport
88
@reexport using StochasticDiffEq
9-
import StochasticDiffEq: stepsize_controller!, accept_step_controller, step_accept_controller!, step_reject_controller!, PIController
9+
import StochasticDiffEq: stepsize_controller!, accept_step_controller,
10+
step_accept_controller!, step_reject_controller!, PIController
1011
# import StochasticDiffEq: calc_J, calc_J!, calc_tderivative!, calc_tderivative
1112
using LinearAlgebra, StaticArrays
1213
using UnPack, DataStructures
1314
using Logging
1415
using RecursiveArrayTools
15-
using DiffEqBase: AbstractSDDEProblem, AbstractSDDEAlgorithm, AbstractRODESolution, AbstractRODEFunction, AbstractSDEIntegrator, AbstractSDDEIntegrator, DEIntegrator, DEAlgorithm, AbstractRODEAlgorithm, AbstractSDEAlgorithm
16+
using DiffEqBase: AbstractSDDEProblem, AbstractSDDEAlgorithm, AbstractRODESolution,
17+
AbstractRODEFunction, AbstractSDEIntegrator, AbstractSDDEIntegrator,
18+
DEIntegrator, DEAlgorithm, AbstractRODEAlgorithm, AbstractSDEAlgorithm
1619

17-
import DelayDiffEq: constant_extrapolant!, constant_extrapolant, AbstractMethodOfStepsAlgorithm, iscomposite, MethodOfSteps
20+
import DelayDiffEq: constant_extrapolant!, constant_extrapolant,
21+
AbstractMethodOfStepsAlgorithm, iscomposite, MethodOfSteps
1822
using DiffEqNoiseProcess
1923

2024
using DelayDiffEq: Discontinuity, HistoryFunction

src/functionwrapper.jl

Lines changed: 55 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,71 @@
1-
struct SDEDiffusionTermWrapper{iip,G,H}
2-
g::G
3-
h::H
1+
struct SDEDiffusionTermWrapper{iip, G, H}
2+
g::G
3+
h::H
44
end
5-
function SDEDiffusionTermWrapper(g::G,h::H) where {G,H}
6-
SDEDiffusionTermWrapper{isinplace(g,5),G,H}(g,h)
5+
function SDEDiffusionTermWrapper(g::G, h::H) where {G, H}
6+
SDEDiffusionTermWrapper{isinplace(g, 5), G, H}(g, h)
77
end
88
(g::SDEDiffusionTermWrapper{true})(du, u, p, t) = g.g(du, u, g.h, p, t)
99
(g::SDEDiffusionTermWrapper{false})(u, p, t) = g.g(u, g.h, p, t)
1010

11-
struct SDEFunctionWrapper{iip,F,G,H,TMM,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,GG,S,TCV} <: DiffEqBase.AbstractRODEFunction{iip}
12-
f::F
13-
g::G
14-
h::H
15-
mass_matrix::TMM
16-
analytic::Ta
17-
tgrad::Tt
18-
jac::TJ
19-
jvp::JVP
20-
vjp::VJP
21-
jac_prototype::JP
22-
sparsity::SP
23-
Wfact::TW
24-
Wfact_t::TWt
25-
paramjac::TPJ
26-
ggprime::GG
27-
syms::S
28-
colorvec::TCV
11+
struct SDEFunctionWrapper{iip, F, G, H, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, TPJ, GG,
12+
S, TCV} <: DiffEqBase.AbstractRODEFunction{iip}
13+
f::F
14+
g::G
15+
h::H
16+
mass_matrix::TMM
17+
analytic::Ta
18+
tgrad::Tt
19+
jac::TJ
20+
jvp::JVP
21+
vjp::VJP
22+
jac_prototype::JP
23+
sparsity::SP
24+
Wfact::TW
25+
Wfact_t::TWt
26+
paramjac::TPJ
27+
ggprime::GG
28+
syms::S
29+
colorvec::TCV
2930
end
3031

31-
3232
(f::SDEFunctionWrapper{true})(du, u, p, t) = f.f(du, u, f.h, p, t)
3333
(f::SDEFunctionWrapper{false})(u, p, t) = f.f(u, f.h, p, t)
3434

3535
function wrap_functions_and_history(f::SDDEFunction, g, h)
36-
gwh = SDEDiffusionTermWrapper{isinplace(g,5),typeof(g),typeof(h)}(g,h)
36+
gwh = SDEDiffusionTermWrapper{isinplace(g, 5), typeof(g), typeof(h)}(g, h)
3737

38-
if f.jac === nothing
39-
jac = nothing
40-
else
41-
if isinplace(f)
42-
jac = let f_jac = f.jac, h = h
43-
(J, u, p, t) -> f_jac(J, u, h, p, t)
44-
end
38+
if f.jac === nothing
39+
jac = nothing
4540
else
46-
jac = let f_jac = f.jac, h = h
47-
(u, p, t) -> f_jac(u, h, p, t)
48-
end
41+
if isinplace(f)
42+
jac = let f_jac = f.jac, h = h
43+
(J, u, p, t) -> f_jac(J, u, h, p, t)
44+
end
45+
else
46+
jac = let f_jac = f.jac, h = h
47+
(u, p, t) -> f_jac(u, h, p, t)
48+
end
49+
end
4950
end
50-
end
5151

52-
SDEFunctionWrapper{isinplace(f),typeof(f.f),typeof(gwh),typeof(h),typeof(f.mass_matrix),
53-
typeof(f.analytic),typeof(f.tgrad),typeof(jac),typeof(f.jvp),
54-
typeof(f.vjp),typeof(f.jac_prototype),typeof(f.sparsity),
55-
typeof(f.Wfact),typeof(f.Wfact_t),typeof(f.paramjac),
56-
typeof(f.ggprime),typeof(f.syms),typeof(f.colorvec)}(
57-
f.f, gwh, h, f.mass_matrix, f.analytic, f.tgrad, jac,
58-
f.jvp, f.vjp,
59-
f.jac_prototype, f.sparsity, f.Wfact, f.Wfact_t,
60-
f.paramjac, f.ggprime, f.syms, f.colorvec), gwh
52+
SDEFunctionWrapper{isinplace(f), typeof(f.f), typeof(gwh), typeof(h),
53+
typeof(f.mass_matrix),
54+
typeof(f.analytic), typeof(f.tgrad), typeof(jac), typeof(f.jvp),
55+
typeof(f.vjp), typeof(f.jac_prototype), typeof(f.sparsity),
56+
typeof(f.Wfact), typeof(f.Wfact_t), typeof(f.paramjac),
57+
typeof(f.ggprime), typeof(f.syms), typeof(f.colorvec)}(f.f, gwh, h,
58+
f.mass_matrix,
59+
f.analytic,
60+
f.tgrad, jac,
61+
f.jvp, f.vjp,
62+
f.jac_prototype,
63+
f.sparsity,
64+
f.Wfact,
65+
f.Wfact_t,
66+
f.paramjac,
67+
f.ggprime,
68+
f.syms,
69+
f.colorvec),
70+
gwh
6171
end

0 commit comments

Comments
 (0)