Skip to content

Commit 7a35464

Browse files
Revert "Apply Runic formatting to all modified files"
This reverts commit b48718a.
1 parent ba5c1ce commit 7a35464

12 files changed

Lines changed: 582 additions & 745 deletions

lib/OrdinaryDiffEqDifferentiation/src/OrdinaryDiffEqDifferentiation.jl

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,40 @@ import ArrayInterface: fast_scalar_indexing, zeromatrix, lu_instance
2020
# import StaticArrayInterface
2121
import StaticArrays
2222
import StaticArrays: SArray, MVector, SVector, @SVector, StaticArray, MMatrix, SA,
23-
StaticMatrix
23+
StaticMatrix
2424

2525
using DiffEqBase: TimeGradientWrapper,
26-
UJacobianWrapper, TimeDerivativeWrapper,
27-
UDerivativeWrapper
26+
UJacobianWrapper, TimeDerivativeWrapper,
27+
UDerivativeWrapper
2828
import SciMLBase: SciMLBase, constructorof, @set, isinplace, has_jvp, unwrapped_f,
29-
DEIntegrator, ODEFunction, SplitFunction, DynamicalODEFunction,
30-
DAEFunction, islinear, remake, solve!, isconstant
29+
DEIntegrator, ODEFunction, SplitFunction, DynamicalODEFunction,
30+
DAEFunction, islinear, remake, solve!, isconstant
3131
using SciMLBase: @set, @reset
3232
import SciMLOperators: SciMLOperators, IdentityOperator, update_coefficients,
33-
update_coefficients!, MatrixOperator, AbstractSciMLOperator,
34-
ScalarOperator
33+
update_coefficients!, MatrixOperator, AbstractSciMLOperator,
34+
ScalarOperator
3535
import SparseMatrixColorings: ConstantColoringAlgorithm, GreedyColoringAlgorithm,
36-
ColoringProblem,
37-
ncolors, column_colors, coloring, sparsity_pattern
36+
ColoringProblem,
37+
ncolors, column_colors, coloring, sparsity_pattern
3838
import OrdinaryDiffEqCore
3939
using OrdinaryDiffEqCore: OrdinaryDiffEqAlgorithm, OrdinaryDiffEqAdaptiveImplicitAlgorithm,
40-
DAEAlgorithm,
41-
OrdinaryDiffEqImplicitAlgorithm, CompositeAlgorithm,
42-
OrdinaryDiffEqExponentialAlgorithm,
43-
OrdinaryDiffEqAdaptiveExponentialAlgorithm,
44-
AbstractNLSolver, nlsolve_f, issplit,
45-
concrete_jac, unwrap_alg, OrdinaryDiffEqCache, _vec, standardtag,
46-
isnewton, _unwrap_val,
47-
set_new_W!, set_W_γdt!, alg_difftype, unwrap_cache, diffdir,
48-
get_W, isfirstcall, isfirststage, isJcurrent,
49-
get_new_W_γdt_cutoff, isWmethod,
50-
TryAgain, DIRK, COEFFICIENT_MULTISTEP, NORDSIECK_MULTISTEP, GLM,
51-
FastConvergence, Convergence, SlowConvergence,
52-
VerySlowConvergence, Divergence, NLStatus, MethodType, constvalue,
53-
@SciMLMessage
40+
DAEAlgorithm,
41+
OrdinaryDiffEqImplicitAlgorithm, CompositeAlgorithm,
42+
OrdinaryDiffEqExponentialAlgorithm,
43+
OrdinaryDiffEqAdaptiveExponentialAlgorithm,
44+
AbstractNLSolver, nlsolve_f, issplit,
45+
concrete_jac, unwrap_alg, OrdinaryDiffEqCache, _vec, standardtag,
46+
isnewton, _unwrap_val,
47+
set_new_W!, set_W_γdt!, alg_difftype, unwrap_cache, diffdir,
48+
get_W, isfirstcall, isfirststage, isJcurrent,
49+
get_new_W_γdt_cutoff, isWmethod,
50+
TryAgain, DIRK, COEFFICIENT_MULTISTEP, NORDSIECK_MULTISTEP, GLM,
51+
FastConvergence, Convergence, SlowConvergence,
52+
VerySlowConvergence, Divergence, NLStatus, MethodType, constvalue,
53+
@SciMLMessage
5454

5555
import OrdinaryDiffEqCore: get_chunksize, resize_J_W!, resize_nlsolver!, alg_autodiff,
56-
_get_fwd_tag
56+
_get_fwd_tag
5757

5858
import ConstructionBase
5959
using ConstructionBase: constructorof

lib/OrdinaryDiffEqDifferentiation/src/alg_utils.jl

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ _alg_autodiff(alg::OrdinaryDiffEqImplicitAlgorithm{CS, AD}) where {CS, AD} = alg
1010
_alg_autodiff(alg::CompositeAlgorithm) = _alg_autodiff(alg.algs[end])
1111
function _alg_autodiff(
1212
alg::Union{
13-
OrdinaryDiffEqExponentialAlgorithm{CS, AD},
14-
OrdinaryDiffEqAdaptiveExponentialAlgorithm{CS, AD},
15-
}
16-
) where {
17-
CS, AD,
18-
}
13+
OrdinaryDiffEqExponentialAlgorithm{CS, AD},
14+
OrdinaryDiffEqAdaptiveExponentialAlgorithm{CS, AD}
15+
}
16+
) where {
17+
CS, AD
18+
}
1919
return alg.autodiff
2020
end
2121

@@ -46,27 +46,27 @@ function DiffEqBase.prepare_alg(
4646
alg::Union{
4747
OrdinaryDiffEqAdaptiveImplicitAlgorithm{
4848
CS, AD,
49-
FDT,
49+
FDT
5050
},
5151
OrdinaryDiffEqImplicitAlgorithm{CS, AD, FDT},
5252
DAEAlgorithm{CS, AD, FDT},
53-
OrdinaryDiffEqExponentialAlgorithm{CS, AD, FDT},
53+
OrdinaryDiffEqExponentialAlgorithm{CS, AD, FDT}
5454
},
5555
u0::AbstractArray{T},
5656
p, prob
57-
) where {CS, AD, FDT, T}
57+
) where {CS, AD, FDT, T}
5858
prepped_AD = prepare_ADType(alg_autodiff(alg), prob, u0, p, standardtag(alg))
5959

6060
sparse_prepped_AD = prepare_user_sparsity(prepped_AD, prob)
6161

6262
# if u0 is a StaticArray or eltype is Complex etc. don't use sparsity
6363
if (
64-
(
65-
(typeof(u0) <: StaticArray) || (eltype(u0) <: Complex) ||
66-
(!(prob.f isa DAEFunction) && prob.f.mass_matrix isa MatrixOperator)
67-
) &&
68-
sparse_prepped_AD isa AutoSparse
69-
)
64+
(
65+
(typeof(u0) <: StaticArray) || (eltype(u0) <: Complex) ||
66+
(!(prob.f isa DAEFunction) && prob.f.mass_matrix isa MatrixOperator)
67+
) &&
68+
sparse_prepped_AD isa AutoSparse
69+
)
7070
@warn "Input type or problem definition is incompatible with sparse automatic differentiation. Switching to using dense automatic differentiation."
7171
autodiff = ADTypes.dense_ad(sparse_prepped_AD)
7272
else
@@ -96,12 +96,12 @@ function prepare_ADType(autodiff_alg::AutoForwardDiff, prob, u0, p, standardtag)
9696
cs = fwd_cs == 0 ? nothing : fwd_cs
9797

9898
if (
99-
(
100-
prob.f isa ODEFunction &&
101-
prob.f.f isa FunctionWrappersWrappers.FunctionWrappersWrapper
102-
) ||
103-
(isbitstype(T) && sizeof(T) > 24)
104-
) && (cs == 0 || isnothing(cs))
99+
(
100+
prob.f isa ODEFunction &&
101+
prob.f.f isa FunctionWrappersWrappers.FunctionWrappersWrapper
102+
) ||
103+
(isbitstype(T) && sizeof(T) > 24)
104+
) && (cs == 0 || isnothing(cs))
105105
return AutoForwardDiff{1}(tag)
106106
else
107107
return AutoForwardDiff{cs}(tag)
@@ -112,9 +112,9 @@ function prepare_ADType(alg::AutoFiniteDiff, prob, u0, p, standardtag)
112112
# If the autodiff alg is AutoFiniteDiff, prob.f.f isa FunctionWrappersWrapper,
113113
# and fdtype is complex, fdtype needs to change to something not complex
114114
if alg.fdtype == Val{:complex}() && (
115-
prob.f isa ODEFunction &&
116-
prob.f.f isa FunctionWrappersWrappers.FunctionWrappersWrapper
117-
)
115+
prob.f isa ODEFunction &&
116+
prob.f.f isa FunctionWrappersWrappers.FunctionWrappersWrapper
117+
)
118118
@warn "AutoFiniteDiff fdtype complex is not compatible with this function"
119119
return AutoFiniteDiff(fdtype = Val{:forward}())
120120
end
@@ -152,9 +152,9 @@ function prepare_user_sparsity(ad_alg, prob)
152152
sparsity = sparsity isa MatrixOperator ? sparsity.A : sparsity
153153

154154
color_alg = SciMLBase.has_colorvec(prob.f) ?
155-
ConstantColoringAlgorithm(
156-
sparsity, prob.f.colorvec
157-
) : GreedyColoringAlgorithm()
155+
ConstantColoringAlgorithm(
156+
sparsity, prob.f.colorvec
157+
) : GreedyColoringAlgorithm()
158158

159159
sparsity_detector = ADTypes.KnownJacobianSparsityDetector(sparsity)
160160

lib/OrdinaryDiffEqDifferentiation/src/derivative_wrappers.jl

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ function jacobian(f::F, x::AbstractArray{<:Number}, integrator) where {F}
8686
sparsity, colorvec = sparsity_colorvec(integrator.f, x)
8787
maxcolor = maximum(colorvec)
8888
chunk_size = (get_chunksize(alg) == Val(0) || get_chunksize(alg) == Val(nothing)) ?
89-
nothing : get_chunksize(alg)
89+
nothing : get_chunksize(alg)
9090
num_of_chunks = div(
9191
maxcolor,
9292
isnothing(chunk_size) ?
93-
getsize(ForwardDiff.pickchunksize(maxcolor)) : _unwrap_val(chunk_size),
93+
getsize(ForwardDiff.pickchunksize(maxcolor)) : _unwrap_val(chunk_size),
9494
RoundUp
9595
)
9696

@@ -189,7 +189,7 @@ function jacobian!(
189189
J::AbstractMatrix{<:Number}, f::F, x::AbstractArray{<:Number},
190190
fx::AbstractArray{<:Number}, integrator::SciMLBase.DEIntegrator,
191191
jac_config
192-
) where {F}
192+
) where {F}
193193
# Handle empty state vector - nothing to compute
194194
if isempty(x)
195195
return nothing
@@ -206,17 +206,17 @@ function jacobian!(
206206
sparsity, colorvec = sparsity_colorvec(integrator.f, x)
207207
maxcolor = maximum(colorvec)
208208
chunk_size = (
209-
get_chunksize(alg) == Val(0) ||
210-
get_chunksize(alg) == Val(nothing)
211-
) ? nothing : get_chunksize(alg)
209+
get_chunksize(alg) == Val(0) ||
210+
get_chunksize(alg) == Val(nothing)
211+
) ? nothing : get_chunksize(alg)
212212
num_of_chunks = chunk_size === nothing ?
213-
Int(
214-
ceil(
215-
maxcolor /
216-
getsize(ForwardDiff.pickchunksize(maxcolor))
217-
)
218-
) :
219-
Int(ceil(maxcolor / _unwrap_val(chunk_size)))
213+
Int(
214+
ceil(
215+
maxcolor /
216+
getsize(ForwardDiff.pickchunksize(maxcolor))
217+
)
218+
) :
219+
Int(ceil(maxcolor / _unwrap_val(chunk_size)))
220220

221221
integrator.stats.nf += num_of_chunks
222222
end
@@ -256,22 +256,22 @@ end
256256
function build_jac_config(
257257
alg, f::F1, uf::F2, du1, uprev,
258258
u, tmp, du2
259-
) where {F1, F2}
259+
) where {F1, F2}
260260
haslinsolve = hasfield(typeof(alg), :linsolve)
261261

262262
if !SciMLBase.has_jac(f) &&
263-
(!SciMLBase.has_Wfact_t(f)) &&
264-
(
265-
(
266-
concrete_jac(alg) === nothing && (
267-
!haslinsolve || (
268-
haslinsolve &&
269-
(alg.linsolve === nothing || LinearSolve.needs_concrete_A(alg.linsolve))
270-
)
271-
)
272-
) ||
273-
(concrete_jac(alg) !== nothing && concrete_jac(alg))
274-
)
263+
(!SciMLBase.has_Wfact_t(f)) &&
264+
(
265+
(
266+
concrete_jac(alg) === nothing && (
267+
!haslinsolve || (
268+
haslinsolve &&
269+
(alg.linsolve === nothing || LinearSolve.needs_concrete_A(alg.linsolve))
270+
)
271+
)
272+
) ||
273+
(concrete_jac(alg) !== nothing && concrete_jac(alg))
274+
)
275275
jac_prototype = f.jac_prototype
276276

277277
if is_sparse_csc(jac_prototype)
@@ -321,14 +321,14 @@ end
321321

322322
function get_chunksize(
323323
jac_config::ForwardDiff.JacobianConfig{
324-
T,
325-
V,
326-
N,
327-
D,
328-
}
329-
) where {
330-
T, V, N, D,
331-
}
324+
T,
325+
V,
326+
N,
327+
D
328+
}
329+
) where {
330+
T, V, N, D
331+
}
332332
return Val(N)
333333
end # don't degrade compile time information to runtime information
334334

@@ -348,14 +348,12 @@ function resize_jac_config!(cache, integrator)
348348
end
349349

350350
cache.jac_config = (
351-
[
352-
DI.prepare!_jacobian(
353-
uf, cache.du1, config, ad, integrator.u
354-
)
355-
for (ad, config) in zip(
356-
(ad_right, ad_left), cache.jac_config
357-
)
358-
]...,
351+
[DI.prepare!_jacobian(
352+
uf, cache.du1, config, ad, integrator.u
353+
)
354+
for (ad, config) in zip(
355+
(ad_right, ad_left), cache.jac_config
356+
)]...,
359357
)
360358
end
361359
return cache.jac_config
@@ -375,14 +373,12 @@ function resize_grad_config!(cache, integrator)
375373
end
376374

377375
cache.grad_config = (
378-
[
379-
DI.prepare!_derivative(
380-
cache.tf, cache.du1, config, ad, integrator.t
381-
)
382-
for (ad, config) in zip(
383-
(ad_right, ad_left), cache.grad_config
384-
)
385-
]...,
376+
[DI.prepare!_derivative(
377+
cache.tf, cache.du1, config, ad, integrator.t
378+
)
379+
for (ad, config) in zip(
380+
(ad_right, ad_left), cache.grad_config
381+
)]...,
386382
)
387383
end
388384
return cache.grad_config
@@ -451,9 +447,7 @@ function sparsity_colorvec(f::F, x) where {F}
451447
col_alg = GreedyColoringAlgorithm()
452448
col_prob = ColoringProblem()
453449
colorvec = SciMLBase.has_colorvec(f) ? f.colorvec :
454-
(
455-
isnothing(sparsity) ? (1:length(x)) :
456-
column_colors(coloring(sparsity, col_prob, col_alg))
457-
)
450+
(isnothing(sparsity) ? (1:length(x)) :
451+
column_colors(coloring(sparsity, col_prob, col_alg)))
458452
return sparsity, colorvec
459453
end

lib/OrdinaryDiffEqDifferentiation/src/linsolve_utils.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ function dolinsolve(
77
du = nothing, u = nothing, p = nothing, t = nothing,
88
weight = nothing, solverdata = nothing,
99
reltol = integrator === nothing ? nothing : integrator.opts.reltol
10-
)
10+
)
1111
A !== nothing && (linsolve.A = A)
1212
b !== nothing && (linsolve.b = b)
1313
linu !== nothing && (linsolve.u = linu)
1414

1515
Plprev = linsolve.Pl isa LinearSolve.ComposePreconditioner ? linsolve.Pl.outer :
16-
linsolve.Pl
16+
linsolve.Pl
1717
Prprev = linsolve.Pr isa LinearSolve.ComposePreconditioner ? linsolve.Pr.outer :
18-
linsolve.Pr
18+
linsolve.Pr
1919

2020
_alg = unwrap_alg(integrator, true)
2121

2222
_Pl,
23-
_Pr = _alg.precs(
23+
_Pr = _alg.precs(
2424
linsolve.A, du, u, p, t, A !== nothing, Plprev, Prprev,
2525
solverdata
2626
)
@@ -34,12 +34,12 @@ function dolinsolve(
3434
linres = solve!(linsolve; reltol)
3535

3636
ad = alg_autodiff(_alg) isa ADTypes.AutoSparse ? ADTypes.dense_ad(alg_autodiff(_alg)) :
37-
alg_autodiff(_alg)
37+
alg_autodiff(_alg)
3838

3939
# TODO: this ignores the add of the `f` count for add_steps!
4040
if integrator isa SciMLBase.DEIntegrator && _alg.linsolve !== nothing &&
41-
!LinearSolve.needs_concrete_A(_alg.linsolve) &&
42-
linsolve.A isa WOperator && linsolve.A.J isa AbstractSciMLOperator
41+
!LinearSolve.needs_concrete_A(_alg.linsolve) &&
42+
linsolve.A isa WOperator && linsolve.A.J isa AbstractSciMLOperator
4343
if ad isa ADTypes.AutoFiniteDiff || ad isa ADTypes.AutoFiniteDifferences
4444
OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2 * linres.iters)
4545
else

lib/OrdinaryDiffEqDifferentiation/src/operators.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ end
5050

5151
function LinearAlgebra.mul!(
5252
Jv::AbstractArray, J::JVPCache, v::AbstractArray
53-
)
53+
)
5454
J.jvp_op(Jv, v, J.u, J.p, J.t)
5555
return Jv
5656
end
@@ -69,7 +69,7 @@ function prepare_jvp(f::SciMLBase.AbstractDiffEqFunction, du, u, p, t, autodiff)
6969
v,
7070
u,
7171
p,
72-
t,
72+
t
7373
) -> DI.pushforward!(
7474
f, du, (reshape(Jv, size(du)),), di_prep, autodiff, u,
7575
(reshape(v, size(u)),), DI.ConstantOrCache(p), DI.Constant(t)

lib/OrdinaryDiffEqRosenbrock/src/alg_utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function has_stiff_interpolation(
7171
Rodas5P, Rodas5Pe, Rodas5Pr, Rodas6P,
7272
HybridExplicitImplicitRK,
7373
}
74-
)
74+
)
7575
return true
7676
end
7777

0 commit comments

Comments
 (0)