Skip to content

Commit d07044d

Browse files
refactor: format with v2
1 parent c3ae7f6 commit d07044d

File tree

86 files changed

+607
-349
lines changed

Some content is hidden

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

86 files changed

+607
-349
lines changed

docs/src/API/variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ For systems that contain parameters with metadata like described above, have som
293293
In the example below, we define a system with tunable parameters and extract bounds vectors
294294

295295
```@example metadata
296-
@variables x(t)=0 u(t)=0 [input = true] y(t)=0 [output = true]
296+
@variables x(t)=0 u(t)=0 [input=true] y(t)=0 [output=true]
297297
@parameters T [tunable = true, bounds = (0, Inf)]
298298
@parameters k [tunable = true, bounds = (0, Inf)]
299299
eqs = [D(x) ~ (-x + k * u) / T # A first-order system with time constant T and gain k

docs/src/basics/Events.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ The basic purely symbolic continuous event interface to encode *one* continuous
9292
event is
9393

9494
```julia
95-
AbstractSystem(eqs, ...; continuous_events::Vector{Equation})
96-
AbstractSystem(eqs, ...; continuous_events::Pair{Vector{Equation}, Vector{Equation}})
95+
AbstractSystem(eqs, _...; continuous_events::Vector{Equation})
96+
AbstractSystem(eqs, _...; continuous_events::Pair{Vector{Equation}, Vector{Equation}})
9797
```
9898

9999
In the former, equations that evaluate to 0 will represent conditions that should
@@ -272,7 +272,7 @@ In addition to continuous events, discrete events are also supported. The
272272
general interface to represent a collection of discrete events is
273273

274274
```julia
275-
AbstractSystem(eqs, ...; discrete_events = [condition1 => affect1, condition2 => affect2])
275+
AbstractSystem(eqs, _...; discrete_events = [condition1 => affect1, condition2 => affect2])
276276
```
277277

278278
where conditions are symbolic expressions that should evaluate to `true` when an
@@ -497,7 +497,8 @@ so far we aren't using anything that's not possible with the implicit interface.
497497
You can also write
498498

499499
```julia
500-
[temp ~ furnace_off_threshold] => ModelingToolkit.ImperativeAffect(modified = (;
500+
[temp ~
501+
furnace_off_threshold] => ModelingToolkit.ImperativeAffect(modified = (;
501502
furnace_on)) do x, o, i, c
502503
@set! x.furnace_on = false
503504
end

docs/src/basics/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The same principle applies to any parameter type that is not `Float64`.
6363
@parameters p1::Int # integer-valued
6464
@parameters p2::Bool # boolean-valued
6565
@parameters p3::MyCustomStructType # non-numeric
66-
@parameters p4::ComponentArray{...} # non-standard array
66+
@parameters p4::ComponentArray{_...} # non-standard array
6767
```
6868

6969
## Getting the index for a symbol

docs/src/basics/MTKLanguage.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ Refer the following example for different ways to define symbolic arrays.
381381
@parameters begin
382382
p1[1:4]
383383
p2[1:N]
384-
p3[1:N, 1:M] = 10,
384+
p3[1:N,
385+
1:M] = 10,
385386
[description = "A multi-dimensional array of arbitrary length with description"]
386387
(p4[1:N, 1:M] = 10),
387388
[description = "An alternate syntax for p3 to match the syntax of vanilla parameters macro"]

docs/src/basics/Validation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function ModelingToolkit.get_unit(op::typeof(dummycomplex), args)
108108
end
109109
110110
sts = @variables a(t)=0 [unit = u"cm"]
111-
ps = @parameters s=-1 [unit = u"cm"] c=c [unit = u"cm"]
111+
ps = @parameters s=-1 [unit=u"cm"] c=c [unit=u"cm"]
112112
eqs = [D(a) ~ dummycomplex(c, s);]
113113
sys = System(
114114
eqs, t, [sts...;], [ps...;], name = :sys, checks = ~ModelingToolkit.CheckUnits)

docs/src/examples/sparse_jacobians.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,20 @@ function brusselator_2d_loop(du, u, p, t)
2323
@inbounds for I in CartesianIndices((N, N))
2424
i, j = Tuple(I)
2525
x, y = xyd_brusselator[I[1]], xyd_brusselator[I[2]]
26-
ip1, im1, jp1, jm1 = limit(i + 1, N), limit(i - 1, N), limit(j + 1, N),
26+
ip1, im1, jp1,
27+
jm1 = limit(i + 1, N), limit(i - 1, N), limit(j + 1, N),
2728
limit(j - 1, N)
28-
du[i, j, 1] = alpha * (u[im1, j, 1] + u[ip1, j, 1] + u[i, jp1, 1] + u[i, jm1, 1] -
29-
4u[i, j, 1]) +
30-
B + u[i, j, 1]^2 * u[i, j, 2] - (A + 1) * u[i, j, 1] +
31-
brusselator_f(x, y, t)
32-
du[i, j, 2] = alpha * (u[im1, j, 2] + u[ip1, j, 2] + u[i, jp1, 2] + u[i, jm1, 2] -
33-
4u[i, j, 2]) +
34-
A * u[i, j, 1] - u[i, j, 1]^2 * u[i, j, 2]
29+
du[i,
30+
j,
31+
1] = alpha * (u[im1, j, 1] + u[ip1, j, 1] + u[i, jp1, 1] + u[i, jm1, 1] -
32+
4u[i, j, 1]) +
33+
B + u[i, j, 1]^2 * u[i, j, 2] - (A + 1) * u[i, j, 1] +
34+
brusselator_f(x, y, t)
35+
du[i,
36+
j,
37+
2] = alpha * (u[im1, j, 2] + u[ip1, j, 2] + u[i, jp1, 2] + u[i, jm1, 2] -
38+
4u[i, j, 2]) +
39+
A * u[i, j, 1] - u[i, j, 1]^2 * u[i, j, 2]
3540
end
3641
end
3742
p = (3.4, 1.0, 10.0, step(xyd_brusselator))

docs/src/examples/tearing_parallelism.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
1515
1616
# Basic electric components
1717
@connector function Pin(; name)
18-
@variables v(t)=1.0 i(t)=1.0 [connect = Flow]
18+
@variables v(t)=1.0 i(t)=1.0 [connect=Flow]
1919
System(Equation[], t, [v, i], [], name = name)
2020
end
2121
@@ -36,7 +36,7 @@ function ConstantVoltage(; name, V = 1.0)
3636
end
3737
3838
@connector function HeatPort(; name)
39-
@variables T(t)=293.15 Q_flow(t)=0.0 [connect = Flow]
39+
@variables T(t)=293.15 Q_flow(t)=0.0 [connect=Flow]
4040
System(Equation[], t, [T, Q_flow], [], name = name)
4141
end
4242

docs/src/tutorials/disturbance_modeling.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ disturbance_inputs = [ssys.d1, ssys.d2]
188188
P = ssys.system_model
189189
outputs = [P.inertia1.phi, P.inertia2.phi, P.inertia1.w, P.inertia2.w]
190190
191-
(f_oop, f_ip), x_sym, p_sym, io_sys = ModelingToolkit.generate_control_function(
191+
(f_oop, f_ip), x_sym,
192+
p_sym,
193+
io_sys = ModelingToolkit.generate_control_function(
192194
model_with_disturbance, inputs, disturbance_inputs; disturbance_argument = true)
193195
194196
g = ModelingToolkit.build_explicit_observed_function(

docs/src/tutorials/linear_analysis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ This is signified by the name being the middle argument to `connect`.
3939
Of the above mentioned functions, all except for [`open_loop`](@ref) return the output of [`ModelingToolkit.linearize`](@ref), which is
4040

4141
```julia
42-
matrices, simplified_sys = linearize(...)
42+
matrices, simplified_sys = linearize(_...)
4343
# matrices = (; A, B, C, D)
4444
```
4545

ext/MTKCasADiDynamicOptExt.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ function MTK.CasADiDynamicOptProblem(sys::System, op, tspan;
6767
dt = nothing,
6868
steps = nothing,
6969
guesses = Dict(), kwargs...)
70-
prob, _ = MTK.process_DynamicOptProblem(
70+
prob,
71+
_ = MTK.process_DynamicOptProblem(
7172
CasADiDynamicOptProblem, CasADiModel, sys, op, tspan; dt, steps, guesses, kwargs...)
7273
prob
7374
end

ext/MTKInfiniteOptExt.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ function MTK.JuMPDynamicOptProblem(sys::System, op, tspan;
8282
dt = nothing,
8383
steps = nothing,
8484
guesses = Dict(), kwargs...)
85-
prob, _ = MTK.process_DynamicOptProblem(JuMPDynamicOptProblem, InfiniteOptModel, sys,
85+
prob,
86+
_ = MTK.process_DynamicOptProblem(JuMPDynamicOptProblem, InfiniteOptModel, sys,
8687
op, tspan; dt, steps, guesses, kwargs...)
8788
prob
8889
end
@@ -91,7 +92,8 @@ function MTK.InfiniteOptDynamicOptProblem(sys::System, op, tspan;
9192
dt = nothing,
9293
steps = nothing,
9394
guesses = Dict(), kwargs...)
94-
prob, pmap = MTK.process_DynamicOptProblem(
95+
prob,
96+
pmap = MTK.process_DynamicOptProblem(
9597
InfiniteOptDynamicOptProblem, InfiniteOptModel,
9698
sys, op, tspan; dt, steps, guesses, kwargs...)
9799
MTK.add_equational_constraints!(prob.wrapped_model, sys, pmap, tspan)

src/bipartite_graph.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Base.iterate(u::Unassigned, state) = nothing
2929

3030
Base.show(io::IO, ::Unassigned) = printstyled(io, "u"; color = :light_black)
3131

32-
struct Matching{U, V <: AbstractVector} <: AbstractVector{Union{U, Int}} #=> :Unassigned =#
32+
struct Matching{U, V <: AbstractVector} <: AbstractVector{Union{U, Int}}
3333
match::V
3434
inv_match::Union{Nothing, V}
3535
end
@@ -608,6 +608,7 @@ function Graphs.incidence_matrix(g::BipartiteGraph, val = true)
608608
I = Int[]
609609
J = Int[]
610610
for i in 𝑠vertices(g), n in 𝑠neighbors(g, i)
611+
611612
push!(I, i)
612613
push!(J, n)
613614
end

src/deprecations.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ for T in [:ODEProblem, :DDEProblem, :SDEProblem, :SDDEProblem, :DAEProblem,
6262
end
6363

6464
for pType in [SciMLBase.NullParameters, Nothing], uType in [Any, Nothing]
65+
6566
@eval function SciMLBase.$T(sys::System, u0::$uType, tspan, p::$pType; kw...)
6667
ctor = string($T)
6768
pT = string($(QuoteNode(pType)))
@@ -142,6 +143,7 @@ for T in [:NonlinearProblem, :NonlinearLeastSquaresProblem,
142143
end
143144
end
144145
for pType in [SciMLBase.NullParameters, Nothing], uType in [Any, Nothing]
146+
145147
@eval function SciMLBase.$T(sys::System, u0::$uType, p::$pType; kw...)
146148
ctor = string($T)
147149
pT = string($(QuoteNode(pType)))

src/inputoutput.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function same_or_inner_namespace(u, var)
120120
nu == nv || # namespaces are the same
121121
startswith(nv, nu) || # or nv starts with nu, i.e., nv is an inner namespace to nu
122122
occursin(NAMESPACE_SEPARATOR, string(getname(var))) &&
123-
!occursin(NAMESPACE_SEPARATOR, string(getname(u))) # or u is top level but var is internal
123+
!occursin(NAMESPACE_SEPARATOR, string(getname(u))) # or u is top level but var is internal
124124
end
125125

126126
function inner_namespace(u, var)
@@ -129,7 +129,7 @@ function inner_namespace(u, var)
129129
nu == nv && return false
130130
startswith(nv, nu) || # or nv starts with nu, i.e., nv is an inner namespace to nu
131131
occursin(NAMESPACE_SEPARATOR, string(getname(var))) &&
132-
!occursin(NAMESPACE_SEPARATOR, string(getname(u))) # or u is top level but var is internal
132+
!occursin(NAMESPACE_SEPARATOR, string(getname(u))) # or u is top level but var is internal
133133
end
134134

135135
"""

src/linearization.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ function (linfun::LinearizationFunction)(u, p, t)
297297
error("Number of unknown variables ($(linfun.num_states)) does not match the number of input unknowns ($(length(u)))")
298298
integ_cache = (linfun.caches,)
299299
integ = MockIntegrator{true}(u, p, t, fun, integ_cache, nothing)
300-
u, p, success = SciMLBase.get_initial_values(
300+
u, p,
301+
success = SciMLBase.get_initial_values(
301302
linfun.prob, integ, fun, linfun.initializealg, Val(true);
302303
linfun.initialize_kwargs...)
303304
if !success
@@ -744,7 +745,8 @@ function linearize(sys, inputs, outputs; op = Dict(), t = 0.0,
744745
allow_input_derivatives = false,
745746
zero_dummy_der = false,
746747
kwargs...)
747-
lin_fun, ssys = linearization_function(sys,
748+
lin_fun,
749+
ssys = linearization_function(sys,
748750
inputs,
749751
outputs;
750752
zero_dummy_der,

src/modelingtoolkitize/sdeproblem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ function modelingtoolkitize(
2626
odefn = ODEFunction{SciMLBase.isinplace(prob)}(
2727
prob.f.f; mass_matrix = prob.f.mass_matrix, sys = prob.f.sys)
2828
odeprob = ODEProblem(odefn, prob.u0, prob.tspan, prob.p)
29-
sys, vars, params = modelingtoolkitize(
29+
sys, vars,
30+
params = modelingtoolkitize(
3031
odeprob; u_names, p_names, return_symbolic_u0_p = true,
3132
name = gensym(:MTKizedSDE), kwargs...)
3233
t = get_iv(sys)

src/problems/bvproblem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
# for initialization.
1515
_op = has_alg_eqs(sys) ? op : merge(Dict(op), Dict(guesses))
1616

17-
fode, u0, p = process_SciMLProblem(
17+
fode, u0,
18+
p = process_SciMLProblem(
1819
ODEFunction{iip, spec}, sys, _op; guesses,
1920
t = tspan !== nothing ? tspan[1] : tspan, check_compatibility = false, cse,
2021
checkbounds, time_dependent_init = false, expression, kwargs...)

src/problems/daeproblem.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ end
6767
check_complete(sys, DAEProblem)
6868
check_compatibility && check_compatible_system(DAEProblem, sys)
6969

70-
f, du0, u0, p = process_SciMLProblem(DAEFunction{iip, spec}, sys, op;
70+
f, du0,
71+
u0,
72+
p = process_SciMLProblem(DAEFunction{iip, spec}, sys, op;
7173
t = tspan !== nothing ? tspan[1] : tspan, check_length, eval_expression,
7274
eval_module, check_compatibility, implicit_dae = true, expression, kwargs...)
7375

src/problems/ddeproblem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ end
4646
check_complete(sys, DDEProblem)
4747
check_compatibility && check_compatible_system(DDEProblem, sys)
4848

49-
f, u0, p = process_SciMLProblem(DDEFunction{iip, spec}, sys, op;
49+
f, u0,
50+
p = process_SciMLProblem(DDEFunction{iip, spec}, sys, op;
5051
t = tspan !== nothing ? tspan[1] : tspan, check_length, cse, checkbounds,
5152
eval_expression, eval_module, check_compatibility, symbolic_u0 = true,
5253
expression, u0_constructor, kwargs...)

src/problems/discreteproblem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ end
4545
dvs = unknowns(sys)
4646
op = to_varmap(op, dvs)
4747
add_toterms!(op; replace = true)
48-
f, u0, p = process_SciMLProblem(DiscreteFunction{iip, spec}, sys, op;
48+
f, u0,
49+
p = process_SciMLProblem(DiscreteFunction{iip, spec}, sys, op;
4950
t = tspan !== nothing ? tspan[1] : tspan, check_compatibility, expression,
5051
kwargs...)
5152

src/problems/implicitdiscreteproblem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ end
5050
dvs = unknowns(sys)
5151
op = to_varmap(op, dvs)
5252
add_toterms!(op; replace = true)
53-
f, u0, p = process_SciMLProblem(
53+
f, u0,
54+
p = process_SciMLProblem(
5455
ImplicitDiscreteFunction{iip, spec}, sys, op;
5556
t = tspan !== nothing ? tspan[1] : tspan, check_compatibility,
5657
expression, kwargs...)

src/problems/intervalnonlinearproblem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ function SciMLBase.IntervalNonlinearProblem(
3333
u0map = unknowns(sys) .=> uspan[1]
3434
op = anydict([unknowns(sys)[1] => uspan[1]])
3535
merge!(op, to_varmap(parammap, parameters(sys)))
36-
f, u0, p = process_SciMLProblem(IntervalNonlinearFunction, sys, op;
36+
f, u0,
37+
p = process_SciMLProblem(IntervalNonlinearFunction, sys, op;
3738
check_compatibility, expression, kwargs...)
3839

3940
kwargs = process_kwargs(sys; kwargs...)

src/problems/jumpproblem.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
build_initializeprob = false, checkbounds, cse, check_length = false,
2323
kwargs...)
2424
else
25-
_, u0, p = process_SciMLProblem(EmptySciMLFunction{iip}, sys, op;
25+
_, u0,
26+
p = process_SciMLProblem(EmptySciMLFunction{iip}, sys, op;
2627
t = tspan === nothing ? nothing : tspan[1],
2728
check_length = false, build_initializeprob = false, kwargs...)
2829
observedfun = ObservedFunctionCache(sys; eval_expression, eval_module,
@@ -32,7 +33,8 @@
3233
prob = ODEProblem{true}(df, u0, tspan, p; kwargs...)
3334
end
3435
else
35-
_f, u0, p = process_SciMLProblem(EmptySciMLFunction{iip}, sys, op;
36+
_f, u0,
37+
p = process_SciMLProblem(EmptySciMLFunction{iip}, sys, op;
3638
t = tspan === nothing ? nothing : tspan[1], check_length = false, build_initializeprob = false, cse, kwargs...)
3739
f = DiffEqBase.DISCRETE_INPLACE_DEFAULT
3840

src/problems/nonlinearproblem.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ end
6363
end
6464
check_compatibility && check_compatible_system(NonlinearProblem, sys)
6565

66-
f, u0, p = process_SciMLProblem(NonlinearFunction{iip, spec}, sys, op;
66+
f, u0,
67+
p = process_SciMLProblem(NonlinearFunction{iip, spec}, sys, op;
6768
check_length, check_compatibility, expression, kwargs...)
6869

6970
kwargs = process_kwargs(sys; kwargs...)
@@ -79,7 +80,8 @@ end
7980
check_complete(sys, NonlinearLeastSquaresProblem)
8081
check_compatibility && check_compatible_system(NonlinearLeastSquaresProblem, sys)
8182

82-
f, u0, p = process_SciMLProblem(NonlinearFunction{iip}, sys, op;
83+
f, u0,
84+
p = process_SciMLProblem(NonlinearFunction{iip}, sys, op;
8385
check_length, expression, kwargs...)
8486

8587
kwargs = process_kwargs(sys; kwargs...)

src/problems/odeproblem.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ end
7070
check_complete(sys, ODEProblem)
7171
check_compatibility && check_compatible_system(ODEProblem, sys)
7272

73-
f, u0, p = process_SciMLProblem(ODEFunction{iip, spec}, sys, op;
73+
f, u0,
74+
p = process_SciMLProblem(ODEFunction{iip, spec}, sys, op;
7475
t = tspan !== nothing ? tspan[1] : tspan, check_length, eval_expression,
7576
eval_module, expression, check_compatibility, kwargs...)
7677

@@ -88,7 +89,8 @@ end
8889
check_complete(sys, SteadyStateProblem)
8990
check_compatibility && check_compatible_system(SteadyStateProblem, sys)
9091

91-
f, u0, p = process_SciMLProblem(ODEFunction{iip}, sys, op;
92+
f, u0,
93+
p = process_SciMLProblem(ODEFunction{iip}, sys, op;
9294
steady_state = true, check_length, check_compatibility, expression,
9395
time_dependent_init = false, kwargs...)
9496

0 commit comments

Comments
 (0)