Skip to content

Commit 690a255

Browse files
refactor: format
1 parent 1b7261a commit 690a255

File tree

7 files changed

+32
-25
lines changed

7 files changed

+32
-25
lines changed

src/systems/diffeqs/odesystem.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ function Base.:(==)(sys1::ODESystem, sys2::ODESystem)
374374
_eq_unordered(get_unknowns(sys1), get_unknowns(sys2)) &&
375375
_eq_unordered(get_ps(sys1), get_ps(sys2)) &&
376376
_eq_unordered(continuous_events(sys1), continuous_events(sys2)) &&
377-
_eq_unordered(discrete_events(sys1), discrete_events(sys2)) &&
377+
_eq_unordered(discrete_events(sys1), discrete_events(sys2)) &&
378378
all(s1 == s2 for (s1, s2) in zip(get_systems(sys1), get_systems(sys2)))
379379
end
380380

@@ -631,7 +631,8 @@ function build_explicit_observed_function(sys, ts;
631631
oop_fn = Func(args, [],
632632
pre(Let(obsexprs,
633633
return_value,
634-
false)), [Expr(:meta, :propagate_inbounds)]) |> array_wrapper[1] |> oop_mtkp_wrapper |> toexpr
634+
false)), [Expr(:meta, :propagate_inbounds)]) |> array_wrapper[1] |>
635+
oop_mtkp_wrapper |> toexpr
635636

636637
if !checkbounds
637638
oop_fn.args[end] = quote

src/systems/diffeqs/sdesystem.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ function Base.:(==)(sys1::SDESystem, sys2::SDESystem)
285285
_eq_unordered(get_unknowns(sys1), get_unknowns(sys2)) &&
286286
_eq_unordered(get_ps(sys1), get_ps(sys2)) &&
287287
_eq_unordered(continuous_events(sys1), continuous_events(sys2)) &&
288-
_eq_unordered(discrete_events(sys1), discrete_events(sys2)) &&
288+
_eq_unordered(discrete_events(sys1), discrete_events(sys2)) &&
289289
all(s1 == s2 for (s1, s2) in zip(get_systems(sys1), get_systems(sys2)))
290290
end
291291

@@ -771,7 +771,6 @@ function DiffEqBase.SDEProblem{iip, specialize}(
771771
end
772772

773773
function DiffEqBase.SDEProblem(sys::ODESystem, args...; kwargs...)
774-
775774
if any(ModelingToolkit.isbrownian, unknowns(sys))
776775
error("SDESystem constructed by defining Brownian variables with @brownian must be simplified by calling `structural_simplify` before a SDEProblem can be constructed.")
777776
else

src/systems/nonlinear/nonlinearsystem.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ function SciMLBase.SCCNonlinearProblem{iip}(sys::NonlinearSystem, u0map,
710710
# precomputed subexpressions should not contain `banned_vars`
711711
banned_vars = Set{Any}(vcat(_dvs, getproperty.(_obs, (:lhs,))))
712712
filter!(banned_vars) do var
713-
symbolic_type(var) != ArraySymbolic() || all(j -> var[j] in banned_vars, eachindex(var))
713+
symbolic_type(var) != ArraySymbolic() ||
714+
all(j -> var[j] in banned_vars, eachindex(var))
714715
end
715716
state = Dict()
716717
for i in eachindex(_obs)
@@ -772,7 +773,8 @@ function SciMLBase.SCCNonlinearProblem{iip}(sys::NonlinearSystem, u0map,
772773
_obs = scc_obs[i]
773774
cachevars = scc_cachevars[i]
774775
cacheexprs = scc_cacheexprs[i]
775-
_prevobsidxs = vcat(_prevobsidxs, observed_equations_used_by(sys, reduce(vcat, values(cacheexprs); init = [])))
776+
_prevobsidxs = vcat(_prevobsidxs,
777+
observed_equations_used_by(sys, reduce(vcat, values(cacheexprs); init = [])))
776778

777779
if isempty(cachevars)
778780
push!(explicitfuns, Returns(nothing))

test/fmi/fmi.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,10 @@ end
262262
@named adder2 = MTK.FMIComponent(
263263
Val(2); fmu, type = :CS, communication_step_size = 1e-3)
264264
sys, prob = build_looped_adders(adder1, adder2)
265-
sol = solve(prob, Tsit5(); reltol = 1e-8, initializealg = SciMLBase.OverrideInit(nlsolve = FastShortcutNLLSPolyalg(autodiff = AutoFiniteDiff())))
265+
sol = solve(prob,
266+
Tsit5();
267+
reltol = 1e-8,
268+
initializealg = SciMLBase.OverrideInit(nlsolve = FastShortcutNLLSPolyalg(autodiff = AutoFiniteDiff())))
266269
@test truesol(sol.t;
267270
idxs = [truesys.adder1.c, truesys.adder2.c]).usol(
268271
sol.t; idxs = [sys.adder1.c, sys.adder2.c]).u rtol=1e-3

test/initial_values.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,6 @@ end
180180
@parameters p[1:2, 1:2]
181181
@mtkbuild sys = ODESystem(D(x) ~ p * x, t)
182182
# used to throw a `MethodError` complaining about `getindex(::Nothing, ::CartesianIndex{2})`
183-
@test_throws ModelingToolkit.MissingParametersError ODEProblem(sys, [x => ones(2)], (0.0, 1.0))
183+
@test_throws ModelingToolkit.MissingParametersError ODEProblem(
184+
sys, [x => ones(2)], (0.0, 1.0))
184185
end

test/odesystem.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ end
15481548
@testset "`isequal`" begin
15491549
@variables X(t)
15501550
@parameters p d
1551-
eq = D(X) ~ p - d*X
1551+
eq = D(X) ~ p - d * X
15521552

15531553
osys1 = complete(ODESystem([eq], t; name = :osys))
15541554
osys2 = complete(ODESystem([eq], t; name = :osys))
@@ -1559,36 +1559,36 @@ end
15591559

15601560
osys1 = complete(ODESystem([eq], t; name = :osys, continuous_events))
15611561
osys2 = complete(ODESystem([eq], t; name = :osys))
1562-
@test osys1 !== osys2
1562+
@test osys1 !== osys2
15631563

15641564
osys1 = complete(ODESystem([eq], t; name = :osys, discrete_events))
15651565
osys2 = complete(ODESystem([eq], t; name = :osys))
15661566
@test osys1 !== osys2
15671567

15681568
osys1 = complete(ODESystem([eq], t; name = :osys, continuous_events))
15691569
osys2 = complete(ODESystem([eq], t; name = :osys, discrete_events))
1570-
@test osys1 !== osys2
1570+
@test osys1 !== osys2
15711571
end
15721572

15731573
@testset "dae_order_lowering basic test" begin
15741574
@parameters a
15751575
@variables x(t) y(t) z(t)
15761576
@named dae_sys = ODESystem([
1577-
D(x) ~ y,
1578-
0 ~ x + z,
1579-
0 ~ x - y + z
1580-
], t, [z, y, x], [])
1577+
D(x) ~ y,
1578+
0 ~ x + z,
1579+
0 ~ x - y + z
1580+
], t, [z, y, x], [])
15811581

15821582
lowered_dae_sys = dae_order_lowering(dae_sys)
1583-
@variables x1(t) y1(t) z1(t)
1583+
@variables x1(t) y1(t) z1(t)
15841584
expected_eqs = [
15851585
0 ~ x + z,
15861586
0 ~ x - y + z,
15871587
Differential(t)(x) ~ y
15881588
]
15891589
lowered_eqs = equations(lowered_dae_sys)
1590-
sorted_lowered_eqs = sort(lowered_eqs, by=string)
1591-
sorted_expected_eqs = sort(expected_eqs, by=string)
1590+
sorted_lowered_eqs = sort(lowered_eqs, by = string)
1591+
sorted_expected_eqs = sort(expected_eqs, by = string)
15921592
@test sorted_lowered_eqs == sorted_expected_eqs
15931593

15941594
expected_vars = Set([z, y, x])

test/sdesystem.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -882,10 +882,10 @@ end
882882
0.1 * z]
883883

884884
@named sys = ODESystem(eqs, tt, [x, y, z], [σ, ρ, β])
885-
885+
886886
@named de = SDESystem(eqs, noiseeqs, tt, [x, y, z], [σ, ρ, β], tspan = (0.0, 10.0))
887887
de = complete(de)
888-
888+
889889
f = SDEFunctionExpr(de)
890890
@test f isa Expr
891891

@@ -915,7 +915,7 @@ end
915915
@variables X(t)
916916
@parameters p d
917917
@brownian a
918-
seq = D(X) ~ p - d*X + a
918+
seq = D(X) ~ p - d * X + a
919919
@mtkbuild ssys1 = System([seq], t; name = :ssys)
920920
@mtkbuild ssys2 = System([seq], t; name = :ssys)
921921
@test ssys1 == ssys2 # true
@@ -925,15 +925,15 @@ end
925925

926926
@mtkbuild ssys1 = System([seq], t; name = :ssys, continuous_events)
927927
@mtkbuild ssys2 = System([seq], t; name = :ssys)
928-
@test ssys1 !== ssys2
928+
@test ssys1 !== ssys2
929929

930930
@mtkbuild ssys1 = System([seq], t; name = :ssys, discrete_events)
931931
@mtkbuild ssys2 = System([seq], t; name = :ssys)
932932
@test ssys1 !== ssys2
933933

934934
@mtkbuild ssys1 = System([seq], t; name = :ssys, continuous_events)
935935
@mtkbuild ssys2 = System([seq], t; name = :ssys, discrete_events)
936-
@test ssys1 !== ssys2
936+
@test ssys1 !== ssys2
937937
end
938938

939939
@testset "Error when constructing SDESystem without `structural_simplify`" begin
@@ -950,7 +950,8 @@ end
950950
u0map = [x => 1.0, y => 0.0, z => 0.0]
951951
parammap ==> 10.0, β => 26.0, ρ => 2.33]
952952

953-
@test_throws ErrorException("SDESystem constructed by defining Brownian variables with @brownian must be simplified by calling `structural_simplify` before a SDEProblem can be constructed.") SDEProblem(de, u0map, (0.0, 100.0), parammap)
953+
@test_throws ErrorException("SDESystem constructed by defining Brownian variables with @brownian must be simplified by calling `structural_simplify` before a SDEProblem can be constructed.") SDEProblem(
954+
de, u0map, (0.0, 100.0), parammap)
954955
de = structural_simplify(de)
955956
@test SDEProblem(de, u0map, (0.0, 100.0), parammap) isa SDEProblem
956-
end
957+
end

0 commit comments

Comments
 (0)