Skip to content

Commit 47b636c

Browse files
refactor: format
1 parent 2ab8ee8 commit 47b636c

File tree

7 files changed

+24
-12
lines changed

7 files changed

+24
-12
lines changed

src/systems/diffeqs/odesystem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ function ODESystem(eqs, iv; kwargs...)
327327
end
328328
algevars = setdiff(allunknowns, diffvars)
329329

330-
return ODESystem(eqs, iv, collect(Iterators.flatten((diffvars, algevars))), collect(new_ps); kwargs...)
330+
return ODESystem(eqs, iv, collect(Iterators.flatten((diffvars, algevars))),
331+
collect(new_ps); kwargs...)
331332
end
332333

333334
# NOTE: equality does not check cached Jacobian

src/systems/diffeqs/sdesystem.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ function SDESystem(sys::ODESystem, neqs; kwargs...)
273273
SDESystem(equations(sys), neqs, get_iv(sys), unknowns(sys), parameters(sys); kwargs...)
274274
end
275275

276-
function SDESystem(eqs::Vector{Equation}, noiseeqs::AbstractArray, iv; kwargs...)
276+
function SDESystem(eqs::Vector{Equation}, noiseeqs::AbstractArray, iv; kwargs...)
277277
diffvars, allunknowns, ps, eqs = process_equations(eqs, iv)
278278

279279
for eq in get(kwargs, :parameter_dependencies, Equation[])
@@ -309,15 +309,21 @@ function SDESystem(eqs::Vector{Equation}, noiseeqs::AbstractArray, iv; kwargs...
309309
noiseps = OrderedSet()
310310
collect_vars!(noisedvs, noiseps, noiseeqs, iv)
311311
for dv in noisedvs
312-
dv allunknowns || throw(ArgumentError("Variable $dv in noise equations is not an unknown of the system."))
312+
dv allunknowns ||
313+
throw(ArgumentError("Variable $dv in noise equations is not an unknown of the system."))
313314
end
314315
algevars = setdiff(allunknowns, diffvars)
315316

316-
return SDESystem(eqs, noiseeqs, iv, Iterators.flatten((diffvars, algevars)), [ps; collect(noiseps)]; kwargs...)
317+
return SDESystem(eqs, noiseeqs, iv, Iterators.flatten((diffvars, algevars)),
318+
[ps; collect(noiseps)]; kwargs...)
317319
end
318320

319-
SDESystem(eq::Equation, noiseeqs::AbstractArray, args...; kwargs...) = SDESystem([eq], noiseeqs, args...; kwargs...)
320-
SDESystem(eq::Equation, noiseeq, args...; kwargs...) = SDESystem([eq], [noiseeq], args...; kwargs...)
321+
function SDESystem(eq::Equation, noiseeqs::AbstractArray, args...; kwargs...)
322+
SDESystem([eq], noiseeqs, args...; kwargs...)
323+
end
324+
function SDESystem(eq::Equation, noiseeq, args...; kwargs...)
325+
SDESystem([eq], [noiseeq], args...; kwargs...)
326+
end
321327

322328
function Base.:(==)(sys1::SDESystem, sys2::SDESystem)
323329
sys1 === sys2 && return true

src/systems/nonlinear/initializesystem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ end
289289
function is_parameter_solvable(p, pmap, defs, guesses)
290290
p = unwrap(p)
291291
is_variable_floatingpoint(p) || return false
292-
_val1 = pmap isa AbstractDict ? get_possibly_array_fallback_singletons(pmap, p) : nothing
292+
_val1 = pmap isa AbstractDict ? get_possibly_array_fallback_singletons(pmap, p) :
293+
nothing
293294
_val2 = get_possibly_array_fallback_singletons(defs, p)
294295
_val3 = get_possibly_array_fallback_singletons(guesses, p)
295296
# either (missing is a default or was passed to the ODEProblem) or (nothing was passed to

src/utils.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,8 @@ function process_equations(eqs, iv)
12251225
throw(ArgumentError("An ODESystem can only have one independent variable."))
12261226
diffvar in diffvars &&
12271227
throw(ArgumentError("The differential variable $diffvar is not unique in the system of equations."))
1228-
!(symtype(diffvar) === Real || eltype(symtype(diffvar)) === Real) && throw(ArgumentError("Differential variable $diffvar has type $(symtype(diffvar)). Differential variables should not be concretely typed."))
1228+
!(symtype(diffvar) === Real || eltype(symtype(diffvar)) === Real) &&
1229+
throw(ArgumentError("Differential variable $diffvar has type $(symtype(diffvar)). Differential variables should not be concretely typed."))
12291230
push!(diffvars, diffvar)
12301231
end
12311232
push!(diffeq, eq)

test/initializationsystem.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,10 +1285,13 @@ end
12851285
@testset "Solvable array parameters with scalarized guesses" begin
12861286
@variables x(t)
12871287
@parameters p[1:2] q
1288-
@mtkbuild sys = ODESystem(D(x) ~ p[1] + p[2] + q, t; defaults = [p[1] => q, p[2] => 2q], guesses = [p[1] => q, p[2] => 2q])
1288+
@mtkbuild sys = ODESystem(
1289+
D(x) ~ p[1] + p[2] + q, t; defaults = [p[1] => q, p[2] => 2q],
1290+
guesses = [p[1] => q, p[2] => 2q])
12891291
@test ModelingToolkit.is_parameter_solvable(p, Dict(), defaults(sys), guesses(sys))
12901292
prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [q => 2.0])
1291-
@test length(ModelingToolkit.observed(prob.f.initialization_data.initializeprob.f.sys)) == 3
1293+
@test length(ModelingToolkit.observed(prob.f.initialization_data.initializeprob.f.sys)) ==
1294+
3
12921295
sol = solve(prob, Tsit5())
12931296
@test sol.ps[p] [2.0, 4.0]
12941297
end

test/odesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ end
15471547
@testset "Validate input types" begin
15481548
@parameters p d
15491549
@variables X(t)::Int64
1550-
eq = D(X) ~ p - d*X
1550+
eq = D(X) ~ p - d * X
15511551
@test_throws ArgumentError @mtkbuild osys = ODESystem([eq], t)
15521552
@variables Y(t)[1:3]::String
15531553
eq = D(Y) ~ [p, p, p]

test/sdesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ end
874874
@parameters p d
875875
@variables X(t)::Int64
876876
@brownian z
877-
eq2 = D(X) ~ p - d*X + z
877+
eq2 = D(X) ~ p - d * X + z
878878
@test_throws ArgumentError @mtkbuild ssys = System([eq2], t)
879879
noiseeq = [1]
880880
@test_throws ArgumentError @named ssys = SDESystem([eq2], [noiseeq], t)

0 commit comments

Comments
 (0)