Skip to content

Commit eab64f9

Browse files
committed
apply JuliaFormatter
1 parent e283773 commit eab64f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1022
-957
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Preferences = "1.3"
7171
Printf = "1.9"
7272
PyCall = "1.96"
7373
PythonCall = "0.9"
74+
QuasiMonteCarlo = "0.3"
7475
RCall = "0.13.18"
7576
RecipesBase = "0.7.0, 0.8, 1.0"
7677
RecursiveArrayTools = "2.33"
@@ -83,7 +84,6 @@ Statistics = "1"
8384
SymbolicIndexingInterface = "0.2"
8485
Tables = "1"
8586
TruncatedStacktraces = "1"
86-
QuasiMonteCarlo = "0.3"
8787
Zygote = "0.6"
8888
julia = "1.9"
8989

ext/SciMLBaseChainRulesCoreExt.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import ChainRulesCore
55
import ChainRulesCore: NoTangent, @non_differentiable
66

77
function ChainRulesCore.rrule(config::ChainRulesCore.RuleConfig{
8-
>:ChainRulesCore.HasReverseMode,
9-
},
10-
::typeof(getindex),
11-
VA::ODESolution,
12-
sym,
13-
j::Integer)
8+
>:ChainRulesCore.HasReverseMode,
9+
},
10+
::typeof(getindex),
11+
VA::ODESolution,
12+
sym,
13+
j::Integer)
1414
function ODESolution_getindex_pullback(Δ)
1515
i = issymbollike(sym) ? sym_to_index(sym, VA) : sym
1616
if i === nothing
@@ -94,11 +94,11 @@ function ChainRulesCore.rrule(::Type{SDEProblem}, args...; kwargs...)
9494
end
9595

9696
function ChainRulesCore.rrule(::Type{
97-
<:ODESolution{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
98-
T11, T12,
99-
}}, u,
100-
args...) where {T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
101-
T12}
97+
<:ODESolution{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
98+
T11, T12,
99+
}}, u,
100+
args...) where {T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
101+
T12}
102102
function ODESolutionAdjoint(ȳ)
103103
(NoTangent(), ȳ, ntuple(_ -> NoTangent(), length(args))...)
104104
end
@@ -108,10 +108,10 @@ function ChainRulesCore.rrule(::Type{
108108
end
109109

110110
function ChainRulesCore.rrule(::Type{
111-
<:ODESolution{uType, tType, isinplace, P, NP, F, G, K,
112-
ND,
113-
}}, u,
114-
args...) where {uType, tType, isinplace, P, NP, F, G, K, ND}
111+
<:ODESolution{uType, tType, isinplace, P, NP, F, G, K,
112+
ND,
113+
}}, u,
114+
args...) where {uType, tType, isinplace, P, NP, F, G, K, ND}
115115
function SDESolutionAdjoint(ȳ)
116116
(NoTangent(), ȳ, ntuple(_ -> NoTangent(), length(args))...)
117117
end
@@ -132,4 +132,4 @@ function ChainRulesCore.rrule(::SciMLBase.EnsembleSolution, sim, time, converged
132132
out, EnsembleSolution_adjoint
133133
end
134134

135-
end
135+
end

ext/SciMLBasePythonCallExt.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ function SciMLBase.numargs(f::Py)
1313
pyconvert(Int, length(first(inspect.getfullargspec(f2))) - inspect.ismethod(f2))
1414
end
1515

16-
_pyconvert(x::Py) = pyisinstance(x, pybuiltins.list) ? _promoting_collect(_pyconvert(x) for x in x) : pyconvert(Any, x)
16+
function _pyconvert(x::Py)
17+
pyisinstance(x, pybuiltins.list) ? _promoting_collect(_pyconvert(x) for x in x) :
18+
pyconvert(Any, x)
19+
end
1720
_pyconvert(x::PyList) = _promoting_collect(_pyconvert(x) for x in x)
1821
_pyconvert(x) = x
1922

ext/SciMLBaseRCallExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ function SciMLBase.isinplace(f::RFunction, args...; kwargs...)
88
false
99
end
1010

11-
end
11+
end

ext/SciMLBaseZygoteExt.jl

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ using Zygote
44
using Zygote: @adjoint, pullback
55
import Zygote: literal_getproperty
66
using SciMLBase
7-
using SciMLBase: ODESolution, issymbollike, sym_to_index, remake,
8-
getobserved, build_solution, EnsembleSolution,
9-
NonlinearSolution, AbstractTimeseriesSolution
7+
using SciMLBase: ODESolution, issymbollike, sym_to_index, remake,
8+
getobserved, build_solution, EnsembleSolution,
9+
NonlinearSolution, AbstractTimeseriesSolution
1010

1111
# This method resolves the ambiguity with the pullback defined in
1212
# RecursiveArrayToolsZygoteExt
@@ -85,7 +85,7 @@ end
8585
end
8686

8787
@adjoint function Zygote.literal_getproperty(sim::EnsembleSolution,
88-
::Val{:u})
88+
::Val{:u})
8989
sim.u, p̄ -> (EnsembleSolution(p̄, 0.0, true, sim.stats),)
9090
end
9191

@@ -107,17 +107,17 @@ end
107107
}(u,
108108
args...) where {T1, T2, T3, T4, T5, T6, T7, T8,
109109
T9, T10, T11, T12}
110-
function ODESolutionAdjoint(ȳ)
111-
(ȳ, ntuple(_ -> nothing, length(args))...)
112-
end
113-
114-
ODESolution{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12}(u, args...),
115-
ODESolutionAdjoint
110+
function ODESolutionAdjoint(ȳ)
111+
(ȳ, ntuple(_ -> nothing, length(args))...)
112+
end
113+
114+
ODESolution{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12}(u, args...),
115+
ODESolutionAdjoint
116116
end
117117

118118
@adjoint function SDEProblem{uType, tType, isinplace, P, NP, F, G, K, ND}(u,
119-
args...) where
120-
{uType, tType, isinplace, P, NP, F, G, K, ND}
119+
args...) where
120+
{uType, tType, isinplace, P, NP, F, G, K, ND}
121121
function SDESolutionAdjoint(ȳ)
122122
(ȳ, ntuple(_ -> nothing, length(args))...)
123123
end
@@ -126,24 +126,24 @@ end
126126
end
127127

128128
@adjoint function NonlinearSolution{T, N, uType, R, P, A, O, uType2}(u,
129-
args...) where {
130-
T,
131-
N,
132-
uType,
133-
R,
134-
P,
135-
A,
136-
O,
137-
uType2,
138-
}
129+
args...) where {
130+
T,
131+
N,
132+
uType,
133+
R,
134+
P,
135+
A,
136+
O,
137+
uType2,
138+
}
139139
function NonlinearSolutionAdjoint(ȳ)
140140
(ȳ, ntuple(_ -> nothing, length(args))...)
141141
end
142142
NonlinearSolution{T, N, uType, R, P, A, O, uType2}(u, args...), NonlinearSolutionAdjoint
143143
end
144144

145145
@adjoint function literal_getproperty(sol::AbstractTimeseriesSolution,
146-
::Val{:u})
146+
::Val{:u})
147147
function solu_adjoint(Δ)
148148
zerou = zero(sol.prob.u0)
149149
= @. ifelse=== nothing, (zerou,), Δ)
@@ -153,7 +153,7 @@ end
153153
end
154154

155155
@adjoint function literal_getproperty(sol::SciMLBase.AbstractNoTimeSolution,
156-
::Val{:u})
156+
::Val{:u})
157157
function solu_adjoint(Δ)
158158
zerou = zero(sol.prob.u0)
159159
= @. ifelse=== nothing, zerou, Δ)
@@ -163,7 +163,7 @@ end
163163
end
164164

165165
@adjoint function literal_getproperty(sol::SciMLBase.OptimizationSolution,
166-
::Val{:u})
166+
::Val{:u})
167167
function solu_adjoint(Δ)
168168
zerou = zero(sol.u)
169169
= @. ifelse=== nothing, zerou, Δ)
@@ -214,8 +214,8 @@ end
214214
end
215215

216216
@adjoint function SciMLBase.responsible_map(f,
217-
args::Union{AbstractArray, Tuple
218-
}...)
217+
args::Union{AbstractArray, Tuple
218+
}...)
219219
∇responsible_map(__context__, f, args...)
220220
end
221221

src/SciMLBase.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -653,23 +653,23 @@ function unwrapped_f(f::FunctionWrappersWrappers.FunctionWrappersWrapper)
653653
end
654654

655655
function specialization(::Union{ODEFunction{iip, specialize},
656-
SDEFunction{iip, specialize}, DDEFunction{iip, specialize},
657-
SDDEFunction{iip, specialize},
658-
DAEFunction{iip, specialize},
659-
DynamicalODEFunction{iip, specialize},
660-
SplitFunction{iip, specialize},
661-
DynamicalSDEFunction{iip, specialize},
662-
SplitSDEFunction{iip, specialize},
663-
DynamicalDDEFunction{iip, specialize},
664-
DiscreteFunction{iip, specialize},
665-
ImplicitDiscreteFunction{iip, specialize},
666-
RODEFunction{iip, specialize},
667-
NonlinearFunction{iip, specialize},
668-
OptimizationFunction{iip, specialize},
669-
BVPFunction{iip, specialize},
670-
IntegralFunction{iip, specialize},
671-
BatchIntegralFunction{iip, specialize}}) where {iip,
672-
specialize}
656+
SDEFunction{iip, specialize}, DDEFunction{iip, specialize},
657+
SDDEFunction{iip, specialize},
658+
DAEFunction{iip, specialize},
659+
DynamicalODEFunction{iip, specialize},
660+
SplitFunction{iip, specialize},
661+
DynamicalSDEFunction{iip, specialize},
662+
SplitSDEFunction{iip, specialize},
663+
DynamicalDDEFunction{iip, specialize},
664+
DiscreteFunction{iip, specialize},
665+
ImplicitDiscreteFunction{iip, specialize},
666+
RODEFunction{iip, specialize},
667+
NonlinearFunction{iip, specialize},
668+
OptimizationFunction{iip, specialize},
669+
BVPFunction{iip, specialize},
670+
IntegralFunction{iip, specialize},
671+
BatchIntegralFunction{iip, specialize}}) where {iip,
672+
specialize}
673673
specialize
674674
end
675675

src/callbacks.jl

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ struct ContinuousCallback{F1, F2, F3, F4, F5, T, T2, T3, I, R} <: AbstractContin
106106
reltol::T2
107107
repeat_nudge::T3
108108
function ContinuousCallback(condition::F1, affect!::F2, affect_neg!::F3,
109-
initialize::F4, finalize::F5, idxs::I, rootfind,
110-
interp_points, save_positions, dtrelax::R, abstol::T,
111-
reltol::T2,
112-
repeat_nudge::T3) where {F1, F2, F3, F4, F5, T, T2, T3, I, R
113-
}
109+
initialize::F4, finalize::F5, idxs::I, rootfind,
110+
interp_points, save_positions, dtrelax::R, abstol::T,
111+
reltol::T2,
112+
repeat_nudge::T3) where {F1, F2, F3, F4, F5, T, T2, T3, I, R
113+
}
114114
new{F1, F2, F3, F4, F5, T, T2, T3, I, R}(condition,
115115
affect!, affect_neg!,
116116
initialize, finalize, idxs, rootfind,
@@ -121,15 +121,15 @@ struct ContinuousCallback{F1, F2, F3, F4, F5, T, T2, T3, I, R} <: AbstractContin
121121
end
122122

123123
function ContinuousCallback(condition, affect!, affect_neg!;
124-
initialize = INITIALIZE_DEFAULT,
125-
finalize = FINALIZE_DEFAULT,
126-
idxs = nothing,
127-
rootfind = LeftRootFind,
128-
save_positions = (true, true),
129-
interp_points = 10,
130-
dtrelax = 1,
131-
abstol = 10eps(), reltol = 0,
132-
repeat_nudge = 1 // 100)
124+
initialize = INITIALIZE_DEFAULT,
125+
finalize = FINALIZE_DEFAULT,
126+
idxs = nothing,
127+
rootfind = LeftRootFind,
128+
save_positions = (true, true),
129+
interp_points = 10,
130+
dtrelax = 1,
131+
abstol = 10eps(), reltol = 0,
132+
repeat_nudge = 1 // 100)
133133
ContinuousCallback(condition, affect!, affect_neg!, initialize, finalize,
134134
idxs,
135135
rootfind, interp_points,
@@ -138,15 +138,15 @@ function ContinuousCallback(condition, affect!, affect_neg!;
138138
end
139139

140140
function ContinuousCallback(condition, affect!;
141-
initialize = INITIALIZE_DEFAULT,
142-
finalize = FINALIZE_DEFAULT,
143-
idxs = nothing,
144-
rootfind = LeftRootFind,
145-
save_positions = (true, true),
146-
affect_neg! = affect!,
147-
interp_points = 10,
148-
dtrelax = 1,
149-
abstol = 10eps(), reltol = 0, repeat_nudge = 1 // 100)
141+
initialize = INITIALIZE_DEFAULT,
142+
finalize = FINALIZE_DEFAULT,
143+
idxs = nothing,
144+
rootfind = LeftRootFind,
145+
save_positions = (true, true),
146+
affect_neg! = affect!,
147+
interp_points = 10,
148+
dtrelax = 1,
149+
abstol = 10eps(), reltol = 0, repeat_nudge = 1 // 100)
150150
ContinuousCallback(condition, affect!, affect_neg!, initialize, finalize, idxs,
151151
rootfind, interp_points,
152152
collect(save_positions),
@@ -211,11 +211,11 @@ struct VectorContinuousCallback{F1, F2, F3, F4, F5, T, T2, T3, I, R} <:
211211
reltol::T2
212212
repeat_nudge::T3
213213
function VectorContinuousCallback(condition::F1, affect!::F2, affect_neg!::F3, len::Int,
214-
initialize::F4, finalize::F5, idxs::I, rootfind,
215-
interp_points, save_positions, dtrelax::R,
216-
abstol::T, reltol::T2,
217-
repeat_nudge::T3) where {F1, F2, F3, F4, F5, T, T2,
218-
T3, I, R}
214+
initialize::F4, finalize::F5, idxs::I, rootfind,
215+
interp_points, save_positions, dtrelax::R,
216+
abstol::T, reltol::T2,
217+
repeat_nudge::T3) where {F1, F2, F3, F4, F5, T, T2,
218+
T3, I, R}
219219
new{F1, F2, F3, F4, F5, T, T2, T3, I, R}(condition,
220220
affect!, affect_neg!, len,
221221
initialize, finalize, idxs, rootfind,
@@ -226,14 +226,14 @@ struct VectorContinuousCallback{F1, F2, F3, F4, F5, T, T2, T3, I, R} <:
226226
end
227227

228228
function VectorContinuousCallback(condition, affect!, affect_neg!, len;
229-
initialize = INITIALIZE_DEFAULT,
230-
finalize = FINALIZE_DEFAULT,
231-
idxs = nothing,
232-
rootfind = LeftRootFind,
233-
save_positions = (true, true),
234-
interp_points = 10,
235-
dtrelax = 1,
236-
abstol = 10eps(), reltol = 0, repeat_nudge = 1 // 100)
229+
initialize = INITIALIZE_DEFAULT,
230+
finalize = FINALIZE_DEFAULT,
231+
idxs = nothing,
232+
rootfind = LeftRootFind,
233+
save_positions = (true, true),
234+
interp_points = 10,
235+
dtrelax = 1,
236+
abstol = 10eps(), reltol = 0, repeat_nudge = 1 // 100)
237237
VectorContinuousCallback(condition, affect!, affect_neg!, len,
238238
initialize, finalize,
239239
idxs,
@@ -243,15 +243,15 @@ function VectorContinuousCallback(condition, affect!, affect_neg!, len;
243243
end
244244

245245
function VectorContinuousCallback(condition, affect!, len;
246-
initialize = INITIALIZE_DEFAULT,
247-
finalize = FINALIZE_DEFAULT,
248-
idxs = nothing,
249-
rootfind = LeftRootFind,
250-
save_positions = (true, true),
251-
affect_neg! = affect!,
252-
interp_points = 10,
253-
dtrelax = 1,
254-
abstol = 10eps(), reltol = 0, repeat_nudge = 1 // 100)
246+
initialize = INITIALIZE_DEFAULT,
247+
finalize = FINALIZE_DEFAULT,
248+
idxs = nothing,
249+
rootfind = LeftRootFind,
250+
save_positions = (true, true),
251+
affect_neg! = affect!,
252+
interp_points = 10,
253+
dtrelax = 1,
254+
abstol = 10eps(), reltol = 0, repeat_nudge = 1 // 100)
255255
VectorContinuousCallback(condition, affect!, affect_neg!, len, initialize, finalize,
256256
idxs,
257257
rootfind, interp_points,
@@ -297,16 +297,16 @@ struct DiscreteCallback{F1, F2, F3, F4} <: AbstractDiscreteCallback
297297
finalize::F4
298298
save_positions::BitArray{1}
299299
function DiscreteCallback(condition::F1, affect!::F2,
300-
initialize::F3, finalize::F4,
301-
save_positions) where {F1, F2, F3, F4}
300+
initialize::F3, finalize::F4,
301+
save_positions) where {F1, F2, F3, F4}
302302
new{F1, F2, F3, F4}(condition,
303303
affect!, initialize, finalize,
304304
BitArray(collect(save_positions)))
305305
end
306306
end
307307
function DiscreteCallback(condition, affect!;
308-
initialize = INITIALIZE_DEFAULT, finalize = FINALIZE_DEFAULT,
309-
save_positions = (true, true))
308+
initialize = INITIALIZE_DEFAULT, finalize = FINALIZE_DEFAULT,
309+
save_positions = (true, true))
310310
DiscreteCallback(condition, affect!, initialize, finalize, save_positions)
311311
end
312312

0 commit comments

Comments
 (0)