Skip to content

Commit b25edc0

Browse files
Merge pull request #3361 from AayushSabharwal/as/fmt
refactor: format
2 parents 6b7d5dc + 690a255 commit b25edc0

File tree

7 files changed

+31
-24
lines changed

7 files changed

+31
-24
lines changed

src/systems/diffeqs/odesystem.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ function Base.:(==)(sys1::ODESystem, sys2::ODESystem)
341341
_eq_unordered(get_unknowns(sys1), get_unknowns(sys2)) &&
342342
_eq_unordered(get_ps(sys1), get_ps(sys2)) &&
343343
_eq_unordered(continuous_events(sys1), continuous_events(sys2)) &&
344-
_eq_unordered(discrete_events(sys1), discrete_events(sys2)) &&
344+
_eq_unordered(discrete_events(sys1), discrete_events(sys2)) &&
345345
all(s1 == s2 for (s1, s2) in zip(get_systems(sys1), get_systems(sys2)))
346346
end
347347

@@ -598,7 +598,8 @@ function build_explicit_observed_function(sys, ts;
598598
oop_fn = Func(args, [],
599599
pre(Let(obsexprs,
600600
return_value,
601-
false)), [Expr(:meta, :propagate_inbounds)]) |> array_wrapper[1] |> oop_mtkp_wrapper |> toexpr
601+
false)), [Expr(:meta, :propagate_inbounds)]) |> array_wrapper[1] |>
602+
oop_mtkp_wrapper |> toexpr
602603

603604
if !checkbounds
604605
oop_fn.args[end] = quote

src/systems/diffeqs/sdesystem.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ function Base.:(==)(sys1::SDESystem, sys2::SDESystem)
331331
_eq_unordered(get_unknowns(sys1), get_unknowns(sys2)) &&
332332
_eq_unordered(get_ps(sys1), get_ps(sys2)) &&
333333
_eq_unordered(continuous_events(sys1), continuous_events(sys2)) &&
334-
_eq_unordered(discrete_events(sys1), discrete_events(sys2)) &&
334+
_eq_unordered(discrete_events(sys1), discrete_events(sys2)) &&
335335
all(s1 == s2 for (s1, s2) in zip(get_systems(sys1), get_systems(sys2)))
336336
end
337337

@@ -817,7 +817,6 @@ function DiffEqBase.SDEProblem{iip, specialize}(
817817
end
818818

819819
function DiffEqBase.SDEProblem(sys::ODESystem, args...; kwargs...)
820-
821820
if any(ModelingToolkit.isbrownian, unknowns(sys))
822821
error("SDESystem constructed by defining Brownian variables with @brownian must be simplified by calling `structural_simplify` before a SDEProblem can be constructed.")
823822
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
@@ -1558,7 +1558,7 @@ end
15581558
@testset "`isequal`" begin
15591559
@variables X(t)
15601560
@parameters p d
1561-
eq = D(X) ~ p - d*X
1561+
eq = D(X) ~ p - d * X
15621562

15631563
osys1 = complete(ODESystem([eq], t; name = :osys))
15641564
osys2 = complete(ODESystem([eq], t; name = :osys))
@@ -1569,36 +1569,36 @@ end
15691569

15701570
osys1 = complete(ODESystem([eq], t; name = :osys, continuous_events))
15711571
osys2 = complete(ODESystem([eq], t; name = :osys))
1572-
@test osys1 !== osys2
1572+
@test osys1 !== osys2
15731573

15741574
osys1 = complete(ODESystem([eq], t; name = :osys, discrete_events))
15751575
osys2 = complete(ODESystem([eq], t; name = :osys))
15761576
@test osys1 !== osys2
15771577

15781578
osys1 = complete(ODESystem([eq], t; name = :osys, continuous_events))
15791579
osys2 = complete(ODESystem([eq], t; name = :osys, discrete_events))
1580-
@test osys1 !== osys2
1580+
@test osys1 !== osys2
15811581
end
15821582

15831583
@testset "dae_order_lowering basic test" begin
15841584
@parameters a
15851585
@variables x(t) y(t) z(t)
15861586
@named dae_sys = ODESystem([
1587-
D(x) ~ y,
1588-
0 ~ x + z,
1589-
0 ~ x - y + z
1590-
], t, [z, y, x], [])
1587+
D(x) ~ y,
1588+
0 ~ x + z,
1589+
0 ~ x - y + z
1590+
], t, [z, y, x], [])
15911591

15921592
lowered_dae_sys = dae_order_lowering(dae_sys)
1593-
@variables x1(t) y1(t) z1(t)
1593+
@variables x1(t) y1(t) z1(t)
15941594
expected_eqs = [
15951595
0 ~ x + z,
15961596
0 ~ x - y + z,
15971597
Differential(t)(x) ~ y
15981598
]
15991599
lowered_eqs = equations(lowered_dae_sys)
1600-
sorted_lowered_eqs = sort(lowered_eqs, by=string)
1601-
sorted_expected_eqs = sort(expected_eqs, by=string)
1600+
sorted_lowered_eqs = sort(lowered_eqs, by = string)
1601+
sorted_expected_eqs = sort(expected_eqs, by = string)
16021602
@test sorted_lowered_eqs == sorted_expected_eqs
16031603

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

test/sdesystem.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -893,10 +893,10 @@ end
893893
0.1 * z]
894894

895895
@named sys = ODESystem(eqs, tt, [x, y, z], [σ, ρ, β])
896-
896+
897897
@named de = SDESystem(eqs, noiseeqs, tt, [x, y, z], [σ, ρ, β], tspan = (0.0, 10.0))
898898
de = complete(de)
899-
899+
900900
f = SDEFunctionExpr(de)
901901
@test f isa Expr
902902

@@ -926,7 +926,7 @@ end
926926
@variables X(t)
927927
@parameters p d
928928
@brownian a
929-
seq = D(X) ~ p - d*X + a
929+
seq = D(X) ~ p - d * X + a
930930
@mtkbuild ssys1 = System([seq], t; name = :ssys)
931931
@mtkbuild ssys2 = System([seq], t; name = :ssys)
932932
@test ssys1 == ssys2 # true
@@ -936,15 +936,15 @@ end
936936

937937
@mtkbuild ssys1 = System([seq], t; name = :ssys, continuous_events)
938938
@mtkbuild ssys2 = System([seq], t; name = :ssys)
939-
@test ssys1 !== ssys2
939+
@test ssys1 !== ssys2
940940

941941
@mtkbuild ssys1 = System([seq], t; name = :ssys, discrete_events)
942942
@mtkbuild ssys2 = System([seq], t; name = :ssys)
943943
@test ssys1 !== ssys2
944944

945945
@mtkbuild ssys1 = System([seq], t; name = :ssys, continuous_events)
946946
@mtkbuild ssys2 = System([seq], t; name = :ssys, discrete_events)
947-
@test ssys1 !== ssys2
947+
@test ssys1 !== ssys2
948948
end
949949

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

964-
@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)
964+
@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(
965+
de, u0map, (0.0, 100.0), parammap)
965966
de = structural_simplify(de)
966967
@test SDEProblem(de, u0map, (0.0, 100.0), parammap) isa SDEProblem
967968
end

0 commit comments

Comments
 (0)