Skip to content

Commit 37871a8

Browse files
Merge pull request #493 from ChrisRackauckas-Claude/runic-formatting
Switch from JuliaFormatter to Runic.jl for code formatting
2 parents b0eac25 + 58e3ff8 commit 37871a8

31 files changed

+1464
-922
lines changed

.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: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)
55

66
ENV["GKSwstype"] = "100"
77

8-
makedocs(modules = [DataInterpolations],
8+
makedocs(
9+
modules = [DataInterpolations],
910
sitename = "DataInterpolations.jl",
1011
clean = true,
1112
doctest = false,
1213
linkcheck = true,
13-
format = Documenter.HTML(assets = ["assets/favicon.ico"],
14-
canonical = "https://docs.sciml.ai/DataInterpolations/stable/"),
14+
format = Documenter.HTML(
15+
assets = ["assets/favicon.ico"],
16+
canonical = "https://docs.sciml.ai/DataInterpolations/stable/"
17+
),
1518
linkcheck_ignore = [
1619
"https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/moler/interp.pdf",
1720
],
@@ -23,7 +26,8 @@ makedocs(modules = [DataInterpolations],
2326
"Using with Symbolics/ModelingToolkit" => "symbolics.md",
2427
"Manual" => "manual.md",
2528
"Smooth arc length interpolation" => "arclength_interpolation.md",
26-
"Inverting Integrals" => "inverting_integrals.md"
27-
])
29+
"Inverting Integrals" => "inverting_integrals.md",
30+
]
31+
)
2832

2933
deploydocs(repo = "github.com/SciML/DataInterpolations.jl"; push_preview = true)

ext/DataInterpolationsChainRulesCoreExt.jl

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module DataInterpolationsChainRulesCoreExt
22

33
using DataInterpolations: _interpolate, derivative, AbstractInterpolation,
4-
LinearInterpolation, QuadraticInterpolation,
5-
LagrangeInterpolation, AkimaInterpolation,
6-
BSplineInterpolation, BSplineApprox, get_idx, get_parameters,
7-
munge_data
4+
LinearInterpolation, QuadraticInterpolation,
5+
LagrangeInterpolation, AkimaInterpolation,
6+
BSplineInterpolation, BSplineApprox, get_idx, get_parameters,
7+
munge_data
88
using ChainRulesCore
99

1010
function ChainRulesCore.rrule(::typeof(munge_data), u, t)
@@ -14,11 +14,12 @@ function ChainRulesCore.rrule(::typeof(munge_data), u, t)
1414
@assert (u == u_out && t == t_out)
1515

1616
munge_data_pullback = Δ -> (NoTangent(), Δ[1], Δ[2])
17-
(u_out, t_out), munge_data_pullback
17+
return (u_out, t_out), munge_data_pullback
1818
end
1919

2020
function ChainRulesCore.rrule(
21-
::Type{LinearInterpolation}, u, t, I, p, extrapolate, cache_parameters)
21+
::Type{LinearInterpolation}, u, t, I, p, extrapolate, cache_parameters
22+
)
2223
A = LinearInterpolation(u, t, I, p, extrapolate, cache_parameters)
2324
function LinearInterpolation_pullback(ΔA)
2425
df = NoTangent()
@@ -28,14 +29,15 @@ function ChainRulesCore.rrule(
2829
dp = NoTangent()
2930
dextrapolate = NoTangent()
3031
dcache_parameters = NoTangent()
31-
df, du, dt, dI, dp, dextrapolate, dcache_parameters
32+
return df, du, dt, dI, dp, dextrapolate, dcache_parameters
3233
end
3334

34-
A, LinearInterpolation_pullback
35+
return A, LinearInterpolation_pullback
3536
end
3637

3738
function ChainRulesCore.rrule(
38-
::Type{QuadraticInterpolation}, u, t, I, p, mode, extrapolate, cache_parameters)
39+
::Type{QuadraticInterpolation}, u, t, I, p, mode, extrapolate, cache_parameters
40+
)
3941
A = QuadraticInterpolation(u, t, I, p, mode, extrapolate, cache_parameters)
4042
function LinearInterpolation_pullback(ΔA)
4143
df = NoTangent()
@@ -46,10 +48,10 @@ function ChainRulesCore.rrule(
4648
dmode = NoTangent()
4749
dextrapolate = NoTangent()
4850
dcache_parameters = NoTangent()
49-
df, du, dt, dI, dp, dmode, dextrapolate, dcache_parameters
51+
return df, du, dt, dI, dp, dmode, dextrapolate, dcache_parameters
5052
end
5153

52-
A, LinearInterpolation_pullback
54+
return A, LinearInterpolation_pullback
5355
end
5456

5557
function u_tangent(A::LinearInterpolation, t, Δ)
@@ -66,12 +68,12 @@ function u_tangent(A::LinearInterpolation, t, Δ)
6668
@. out[idx] = Δ * (true - t_factor)
6769
@. out[idx + 1] = Δ * t_factor
6870
end
69-
out
71+
return out
7072
end
7173

7274
function _quad_interp_indices(A::QuadraticInterpolation, t::Number, iguess)
7375
idx = get_idx(A, t, iguess; idx_shift = A.mode == :Backward ? -1 : 0, ub_shift = -2)
74-
idx, idx + 1, idx + 2
76+
return idx, idx + 1, idx + 2
7577
end
7678

7779
function u_tangent(A::QuadraticInterpolation, t, Δ)
@@ -99,32 +101,36 @@ function u_tangent(A::QuadraticInterpolation, t, Δ)
99101
@. out[i₁] = -Δ * Δt_rel₀ * Δt_rel₂ / (Δt₀ * Δt₁)
100102
@. out[i₂] = Δ * Δt_rel₀ * Δt_rel₁ / (Δt₂ * Δt₁)
101103
end
102-
out
104+
return out
103105
end
104106

105107
function u_tangent(A, t, Δ)
106-
NoTangent()
108+
return NoTangent()
107109
end
108110

109-
function ChainRulesCore.rrule(::typeof(_interpolate),
111+
function ChainRulesCore.rrule(
112+
::typeof(_interpolate),
110113
A::Union{
111114
LinearInterpolation,
112115
QuadraticInterpolation,
113116
LagrangeInterpolation,
114117
AkimaInterpolation,
115118
BSplineInterpolation,
116-
BSplineApprox
119+
BSplineApprox,
117120
},
118-
t::Number)
121+
t::Number
122+
)
119123
deriv = derivative(A, t)
120124
function interpolate_pullback(Δ)
121-
(NoTangent(), Tangent{typeof(A)}(; u = u_tangent(A, t, Δ)), sum(deriv .* Δ))
125+
return (NoTangent(), Tangent{typeof(A)}(; u = u_tangent(A, t, Δ)), sum(deriv .* Δ))
122126
end
123127
return _interpolate(A, t), interpolate_pullback
124128
end
125129

126-
function ChainRulesCore.frule((_, _, Δt), ::typeof(_interpolate), A::AbstractInterpolation,
127-
t::Number)
130+
function ChainRulesCore.frule(
131+
(_, _, Δt), ::typeof(_interpolate), A::AbstractInterpolation,
132+
t::Number
133+
)
128134
return _interpolate(A, t), derivative(A, t) * Δt
129135
end
130136

ext/DataInterpolationsMakieExt.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ Makie.plottype(::AbstractInterpolation) = Makie.ScatterLines
99

1010
# Define the attributes that you want to use
1111
function Makie.used_attributes(::Makie.PointBased, ::AbstractInterpolation)
12-
(:plotdensity, :denseplot)
12+
return (:plotdensity, :denseplot)
1313
end
1414
function Makie.used_attributes(::Type{<:Makie.ScatterLines}, ::AbstractInterpolation)
15-
(:plotdensity, :denseplot)
15+
return (:plotdensity, :denseplot)
1616
end
1717

1818
# Define the conversion of the data to the plot
@@ -21,8 +21,8 @@ function Makie.convert_arguments(
2121
A::AbstractInterpolation;
2222
plotdensity = 10_000,
2323
denseplot = true
24-
)
25-
DataInterpolations.to_plottable(A; plotdensity = plotdensity, denseplot = denseplot)
24+
)
25+
return DataInterpolations.to_plottable(A; plotdensity = plotdensity, denseplot = denseplot)
2626
end
2727

2828
# Define the conversion of the data to the plot for the ScatterLines type
@@ -34,12 +34,12 @@ function Makie.convert_arguments(
3434
A::AbstractInterpolation;
3535
plotdensity = 10_000,
3636
denseplot = true
37-
)
37+
)
3838
densex,
39-
densey = convert_arguments(Makie.PointBased(), A; plotdensity = plotdensity, denseplot = denseplot)
39+
densey = convert_arguments(Makie.PointBased(), A; plotdensity = plotdensity, denseplot = denseplot)
4040
return [
4141
Makie.SpecApi.Lines(densex, densey),
42-
Makie.SpecApi.Scatter(A.t, A.u)
42+
Makie.SpecApi.Scatter(A.t, A.u),
4343
]
4444
end
4545

ext/DataInterpolationsOptimExt.jl

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@ module DataInterpolationsOptimExt
22

33
using DataInterpolations
44
import DataInterpolations: munge_data,
5-
Curvefit, CurvefitCache, _interpolate, get_show, derivative,
6-
ExtrapolationError,
7-
integral, IntegralNotFoundError, DerivativeNotFoundError
5+
Curvefit, CurvefitCache, _interpolate, get_show, derivative,
6+
ExtrapolationError,
7+
integral, IntegralNotFoundError, DerivativeNotFoundError
88

99
using Optim, ForwardDiff
1010

1111
### Curvefit
12-
function Curvefit(u,
12+
function Curvefit(
13+
u,
1314
t,
1415
model,
1516
p0,
1617
alg,
1718
box = false,
1819
lb = nothing,
1920
ub = nothing;
20-
extrapolate = false)
21+
extrapolate = false
22+
)
2123
u, t = munge_data(u, t)
2224
errfun(t, u, p) = sum(abs2.(u .- model(t, p)))
2325
if box == false
@@ -30,25 +32,31 @@ function Curvefit(u,
3032
mfit = optimize(od, lb, ub, p0, Fminbox(alg))
3133
end
3234
pmin = Optim.minimizer(mfit)
33-
CurvefitCache(u, t, model, p0, ub, lb, alg, pmin, extrapolate)
35+
return CurvefitCache(u, t, model, p0, ub, lb, alg, pmin, extrapolate)
3436
end
3537

3638
# Curvefit
37-
function _interpolate(A::CurvefitCache{<:AbstractVector{<:Number}},
38-
t::Union{AbstractVector{<:Number}, Number})
39+
function _interpolate(
40+
A::CurvefitCache{<:AbstractVector{<:Number}},
41+
t::Union{AbstractVector{<:Number}, Number}
42+
)
3943
((t < A.t[1] || t > A.t[end]) && !A.extrapolate) &&
4044
throw(ExtrapolationError())
41-
A.m(t, A.pmin)
45+
return A.m(t, A.pmin)
4246
end
4347

44-
function _interpolate(A::CurvefitCache{<:AbstractVector{<:Number}},
48+
function _interpolate(
49+
A::CurvefitCache{<:AbstractVector{<:Number}},
4550
t::Union{AbstractVector{<:Number}, Number},
46-
i)
47-
_interpolate(A, t), i
51+
i
52+
)
53+
return _interpolate(A, t), i
4854
end
4955

50-
function derivative(A::CurvefitCache{<:AbstractVector{<:Number}},
51-
t::Union{AbstractVector{<:Number}, Number}, order = 1)
56+
function derivative(
57+
A::CurvefitCache{<:AbstractVector{<:Number}},
58+
t::Union{AbstractVector{<:Number}, Number}, order = 1
59+
)
5260
((t < A.t[1] || t > A.t[end]) && !A.extrapolate) && throw(ExtrapolationError())
5361
order > 2 && throw(DerivativeNotFoundError())
5462
order == 1 && return ForwardDiff.derivative(x -> A.m(x, A.pmin), t)
@@ -57,7 +65,7 @@ end
5765

5866
function get_show(A::CurvefitCache)
5967
return "Curvefit" *
60-
" with $(length(A.t)) points, using $(nameof(typeof(A.alg)))\n"
68+
" with $(length(A.t)) points, using $(nameof(typeof(A.alg)))\n"
6169
end
6270

6371
function integral(A::CurvefitCache{<:AbstractVector{<:Number}}, t::Number)

0 commit comments

Comments
 (0)