Skip to content

Commit 6dc83cc

Browse files
committed
Fix parsing error and apply JuliaFormatter code formatting
- Fix malformed DiffEqBase.@.. macro syntax in interface.jl:238 - Apply JuliaFormatter to standardize code formatting across the codebase - Updated formatting in integrators, solve logic, and test files - Resolves parsing error that prevented JuliaFormatter from processing the repository 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 33a0719 commit 6dc83cc

File tree

12 files changed

+390
-363
lines changed

12 files changed

+390
-363
lines changed

src/functionwrapper.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ 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,
12-
TCV, ID, S} <: DiffEqBase.AbstractRODEFunction{iip}
11+
struct SDEFunctionWrapper{
12+
iip, F, G, H, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, TPJ, GG,
13+
TCV, ID, S} <: DiffEqBase.AbstractRODEFunction{iip}
1314
f::F
1415
g::G
1516
h::H
@@ -51,13 +52,13 @@ function wrap_functions_and_history(f::SDDEFunction, g, h)
5152
end
5253

5354
SDEFunctionWrapper{isinplace(f), typeof(f.f), typeof(gwh), typeof(h),
54-
typeof(f.mass_matrix),
55-
typeof(f.analytic), typeof(f.tgrad), typeof(jac), typeof(f.jvp),
56-
typeof(f.vjp), typeof(f.jac_prototype), typeof(f.sparsity),
57-
typeof(f.Wfact), typeof(f.Wfact_t), typeof(f.paramjac),
58-
typeof(f.ggprime), typeof(f.colorvec), typeof(f.initialization_data),
59-
typeof(f.sys)}(f.f, gwh, h, f.mass_matrix, f.analytic, f.tgrad, jac,
60-
f.jvp, f.vjp, f.jac_prototype, f.sparsity, f.Wfact, f.Wfact_t, f.paramjac,
61-
f.ggprime, f.colorvec, f.initialization_data, f.sys),
55+
typeof(f.mass_matrix),
56+
typeof(f.analytic), typeof(f.tgrad), typeof(jac), typeof(f.jvp),
57+
typeof(f.vjp), typeof(f.jac_prototype), typeof(f.sparsity),
58+
typeof(f.Wfact), typeof(f.Wfact_t), typeof(f.paramjac),
59+
typeof(f.ggprime), typeof(f.colorvec), typeof(f.initialization_data),
60+
typeof(f.sys)}(f.f, gwh, h, f.mass_matrix, f.analytic, f.tgrad, jac,
61+
f.jvp, f.vjp, f.jac_prototype, f.sparsity, f.Wfact, f.Wfact_t, f.paramjac,
62+
f.ggprime, f.colorvec, f.initialization_data, f.sys),
6263
gwh
6364
end

src/integrators/interface.jl

Lines changed: 83 additions & 78 deletions
Large diffs are not rendered by default.

src/integrators/type.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ function (integrator::HistorySDEIntegrator)(t, deriv::Type = Val{0}; idxs = noth
1818
end
1919

2020
function (integrator::HistorySDEIntegrator)(val::AbstractArray,
21-
t::Union{Number, AbstractArray},
22-
deriv::Type = Val{0}; idxs = nothing)
21+
t::Union{Number, AbstractArray},
22+
deriv::Type = Val{0}; idxs = nothing)
2323
StochasticDiffEq.current_interpolant!(val, t, integrator, idxs, deriv)
2424
end
2525

2626
mutable struct SDDEIntegrator{algType, IIP, uType, uEltype, tType, P, eigenType,
27-
tTypeNoUnits, uEltypeNoUnits, randType, randType2, rateType,
28-
solType, cacheType, F, G, F6, OType, noiseType,
29-
EventErrorType, CallbackCacheType, H, IType, IA} <:
27+
tTypeNoUnits, uEltypeNoUnits, randType, randType2, rateType,
28+
solType, cacheType, F, G, F6, OType, noiseType,
29+
EventErrorType, CallbackCacheType, H, IType, IA} <:
3030
AbstractSDDEIntegrator{algType, IIP, uType, tType}
3131
f::F
3232
g::G
@@ -89,6 +89,6 @@ function (integrator::SDDEIntegrator)(t, deriv::Type = Val{0}; idxs = nothing)
8989
end
9090

9191
function (integrator::SDDEIntegrator)(val::AbstractArray, t::Union{Number, AbstractArray},
92-
deriv::Type = Val{0}; idxs = nothing)
92+
deriv::Type = Val{0}; idxs = nothing)
9393
StochasticDiffEq.current_interpolant!(val, t, integrator, idxs, deriv)
9494
end

src/integrators/utils.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
elseif tdir_t > tdir_ts_top
1010
if !integrator.dtchangeable
1111
change_t_via_interpolation!(integrator, integrator.tdir * pop!(tstops),
12-
Val{true})
12+
Val{true})
1313
integrator.just_hit_tstop = true
1414
else
1515
error("Something went wrong. Integrator stepped past tstops but the algorithm was dtchangeable. Please report this error.")
@@ -55,7 +55,8 @@ function handle_discontinuities!(integrator::SDDEIntegrator)
5555
maxΔt = 10eps(integrator.t)
5656

5757
while !isempty(integrator.opts.d_discontinuities) &&
58-
abs(first(integrator.opts.d_discontinuities).t - integrator.tdir * integrator.t) <
58+
abs(first(integrator.opts.d_discontinuities).t -
59+
integrator.tdir * integrator.t) <
5960
maxΔt
6061
d2 = pop!(integrator.opts.d_discontinuities)
6162
order = min(order, d2.order)

src/solve.jl

Lines changed: 173 additions & 169 deletions
Large diffs are not rendered by default.

src/stepsize_controllers.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ function stepsize_controller!(integrator::SDDEIntegrator, controller::PIControll
44
integrator.q = DiffEqBase.value(integrator.q11 /
55
FastPower.fastpower(integrator.qold, controller.beta2))
66
@fastmath integrator.q = DiffEqBase.value(max(inv(integrator.opts.qmax),
7-
min(inv(integrator.opts.qmin),
8-
integrator.q / integrator.opts.gamma)))
7+
min(inv(integrator.opts.qmin),
8+
integrator.q / integrator.opts.gamma)))
99
end
1010

1111
@inline function step_accept_controller!(integrator::SDDEIntegrator, alg)
@@ -19,5 +19,5 @@ end
1919

2020
function step_reject_controller!(integrator::SDDEIntegrator, controller::PIController, alg)
2121
integrator.dtnew = integrator.dt / min(inv(integrator.opts.qmin),
22-
integrator.q11 / integrator.opts.gamma)
22+
integrator.q11 / integrator.opts.gamma)
2323
end

src/utils.jl

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ Return arrays of saved time points, states, and rates, initialized with the solu
5454
first time point if `save_start = true` (the default).
5555
"""
5656
function solution_arrays(u::uType, tspan, rate_prototype;
57-
timeseries_init = typeof(u)[],
58-
ts_init = eltype(tspan)[],
59-
save_idxs = nothing,
60-
save_start = true) where {uType}
57+
timeseries_init = typeof(u)[],
58+
ts_init = eltype(tspan)[],
59+
save_idxs = nothing,
60+
save_start = true) where {uType}
6161
# determine types of time and state
6262
# uType = typeof(u)
6363
tType = eltype(tspan)
@@ -108,10 +108,10 @@ Suggest that solution `sol` reserves capacity for a number of elements that
108108
depends on the parameter settings of the numerical solver.
109109
"""
110110
function Base.sizehint!(sol::RODESolution, alg, tspan, tstops, saveat;
111-
save_everystep = isempty(saveat),
112-
adaptive = StochasticDiffEq.isadaptive(getalg(alg)),
113-
internalnorm = DiffEqBase.ODE_DEFAULT_NORM,
114-
dt = zero(eltype(tspan)))
111+
save_everystep = isempty(saveat),
112+
adaptive = StochasticDiffEq.isadaptive(getalg(alg)),
113+
internalnorm = DiffEqBase.ODE_DEFAULT_NORM,
114+
dt = zero(eltype(tspan)))
115115
# obtain integration time
116116
t0 = first(tspan)
117117
integrationtime = last(tspan) - t0
@@ -137,11 +137,11 @@ function Base.sizehint!(sol::RODESolution, alg, tspan, tstops, saveat;
137137
end
138138

139139
function build_history_function(prob, alg, reltol, rate_prototype, noise_rate_prototype,
140-
jump_prototype, W, _seed, dense;
141-
dt = zero(eltype(prob.tspan)),
142-
adaptive = StochasticDiffEq.isadaptive(getalg(alg)),
143-
calck = false,
144-
internalnorm = DiffEqBase.ODE_DEFAULT_NORM)
140+
jump_prototype, W, _seed, dense;
141+
dt = zero(eltype(prob.tspan)),
142+
adaptive = StochasticDiffEq.isadaptive(getalg(alg)),
143+
calck = false,
144+
internalnorm = DiffEqBase.ODE_DEFAULT_NORM)
145145
@unpack f, g, h, u0, tspan, p = prob
146146

147147
t0 = first(tspan)
@@ -170,52 +170,53 @@ function build_history_function(prob, alg, reltol, rate_prototype, noise_rate_pr
170170
sde_u, sde_uprev = u_uprev(u0; alias_u0 = false)
171171

172172
# # initialize output arrays
173-
sde_ts, sde_timeseries, sde_saveiter = solution_arrays(sde_u, tspan, rate_prototype,
174-
save_idxs = nothing,
175-
save_start = true)
173+
sde_ts, sde_timeseries,
174+
sde_saveiter = solution_arrays(sde_u, tspan, rate_prototype,
175+
save_idxs = nothing,
176+
save_start = true)
176177

177178
# # obtain cache (we alias uprev2 and uprev)
178179
sde_cache = StochasticDiffEq.alg_cache(getalg(alg), prob, sde_u, W.dW, W.dZ, p,
179-
rate_prototype, noise_rate_prototype,
180-
jump_prototype, uEltypeNoUnits,
181-
uBottomEltypeNoUnits, tTypeNoUnits, sde_uprev, f,
182-
t0, dt, Val{isinplace(prob)})
180+
rate_prototype, noise_rate_prototype,
181+
jump_prototype, uEltypeNoUnits,
182+
uBottomEltypeNoUnits, tTypeNoUnits, sde_uprev, f,
183+
t0, dt, Val{isinplace(prob)})
183184

184185
# build dense interpolation of history
185186
id = StochasticDiffEq.LinearInterpolationData(sde_timeseries, sde_ts)
186187
if typeof(getalg(alg)) <: StochasticDiffEq.StochasticDiffEqCompositeAlgorithm
187188
alg_choice = Int[]
188189
sde_sol = DiffEqBase.build_solution(prob, alg, sde_ts, sde_timeseries, W = W,
189-
stats = DiffEqBase.Stats(0),
190-
calculate_error = false,
191-
alg_choice = alg_choice,
192-
interp = id, dense = dense, seed = _seed)
190+
stats = DiffEqBase.Stats(0),
191+
calculate_error = false,
192+
alg_choice = alg_choice,
193+
interp = id, dense = dense, seed = _seed)
193194
else
194195
sde_sol = DiffEqBase.build_solution(prob, alg, sde_ts, sde_timeseries, W = W,
195-
stats = DiffEqBase.Stats(0),
196-
calculate_error = false,
197-
interp = id, dense = dense, seed = _seed)
196+
stats = DiffEqBase.Stats(0),
197+
calculate_error = false,
198+
interp = id, dense = dense, seed = _seed)
198199
end
199200

200201
# # reserve capacity
201202
sizehint!(sde_sol, getalg(alg), tspan, (), ();
202-
save_everystep = true, adaptive = adaptive, internalnorm = internalnorm,
203-
dt = tType(dt))
203+
save_everystep = true, adaptive = adaptive, internalnorm = internalnorm,
204+
dt = tType(dt))
204205

205206
# # create simple integrator
206207
sde_integrator = HistorySDEIntegrator{typeof(getalg(alg)), isinplace(prob),
207-
typeof(prob.u0),
208-
tType, typeof(sde_sol), typeof(sde_cache)}(sde_sol,
209-
sde_u,
210-
t0,
211-
zero(tType),
212-
sde_uprev,
213-
t0,
214-
getalg(alg),
215-
zero(tType),
216-
tdir,
217-
1,
218-
sde_cache)
208+
typeof(prob.u0),
209+
tType, typeof(sde_sol), typeof(sde_cache)}(sde_sol,
210+
sde_u,
211+
t0,
212+
zero(tType),
213+
sde_uprev,
214+
t0,
215+
getalg(alg),
216+
zero(tType),
217+
tdir,
218+
1,
219+
sde_cache)
219220

220221
# # combine the user-provided history function and the ODE integrator with dense solution
221222
# # to a joint dense history of the DDE

0 commit comments

Comments
 (0)