Skip to content

Commit 0d8ab97

Browse files
committed
New formatter
1 parent 45dfe62 commit 0d8ab97

37 files changed

+538
-538
lines changed

docs/src/tutorials/domain_connections.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ The fluid medium setter for `HydralicPort` may be defined as `HydraulicFluid` wi
3131

3232
```@example domain
3333
@connector function HydraulicFluid(;
34-
density = 997,
35-
bulk_modulus = 2.09e9,
36-
viscosity = 0.0010016,
37-
name)
34+
density = 997,
35+
bulk_modulus = 2.09e9,
36+
viscosity = 0.0010016,
37+
name)
3838
pars = @parameters begin
3939
ρ = density
4040
β = bulk_modulus

ext/MTKBifurcationKitExt.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import BifurcationKit
1010

1111
# When input is a NonlinearSystem.
1212
function BifurcationKit.BifurcationProblem(nsys::NonlinearSystem,
13-
u0_bif,
14-
ps,
15-
bif_par,
16-
args...;
17-
plot_var = nothing,
18-
record_from_solution = BifurcationKit.record_sol_default,
19-
jac = true,
20-
kwargs...)
13+
u0_bif,
14+
ps,
15+
bif_par,
16+
args...;
17+
plot_var = nothing,
18+
record_from_solution = BifurcationKit.record_sol_default,
19+
jac = true,
20+
kwargs...)
2121
# Creates F and J functions.
2222
ofun = NonlinearFunction(nsys; jac = jac)
2323
F = ofun.f

ext/MTKDeepDiffsExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function Base.getindex(ssdpm::SystemStructureDiffPrintMatrix, i::Integer, j::Int
179179
end
180180

181181
function DeepDiffs.deepdiff(old::Union{MatchedSystemStructure, SystemStructure},
182-
new::Union{MatchedSystemStructure, SystemStructure})
182+
new::Union{MatchedSystemStructure, SystemStructure})
183183
new_sspm = SystemStructurePrintMatrix(new)
184184
old_sspm = SystemStructurePrintMatrix(old)
185185
Base.print_matrix(stdout, SystemStructureDiffPrintMatrix(new_sspm, old_sspm))

src/bipartite_graph.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,13 @@ mutable struct BipartiteGraph{I <: Integer, M} <: Graphs.AbstractGraph{I}
169169
metadata::M
170170
end
171171
function BipartiteGraph(ne::Integer, fadj::AbstractVector,
172-
badj::Union{AbstractVector, Integer} = maximum(maximum, fadj);
173-
metadata = nothing)
172+
badj::Union{AbstractVector, Integer} = maximum(maximum, fadj);
173+
metadata = nothing)
174174
BipartiteGraph(ne, fadj, badj, metadata)
175175
end
176176
function BipartiteGraph(fadj::AbstractVector,
177-
badj::Union{AbstractVector, Integer} = maximum(maximum, fadj);
178-
metadata = nothing)
177+
badj::Union{AbstractVector, Integer} = maximum(maximum, fadj);
178+
metadata = nothing)
179179
BipartiteGraph(mapreduce(length, +, fadj; init = 0), fadj, badj, metadata)
180180
end
181181

@@ -325,7 +325,7 @@ $(SIGNATURES)
325325
Build an empty `BipartiteGraph` with `nsrcs` sources and `ndsts` destinations.
326326
"""
327327
function BipartiteGraph(nsrcs::T, ndsts::T, backedge::Val{B} = Val(true);
328-
metadata = nothing) where {T, B}
328+
metadata = nothing) where {T, B}
329329
fadjlist = map(_ -> T[], 1:nsrcs)
330330
badjlist = B ? map(_ -> T[], 1:ndsts) : ndsts
331331
BipartiteGraph(0, fadjlist, badjlist, metadata)
@@ -359,11 +359,11 @@ end
359359
has_𝑠vertex(g::BipartiteGraph, v::Integer) = v in 𝑠vertices(g)
360360
has_𝑑vertex(g::BipartiteGraph, v::Integer) = v in 𝑑vertices(g)
361361
function 𝑠neighbors(g::BipartiteGraph, i::Integer,
362-
with_metadata::Val{M} = Val(false)) where {M}
362+
with_metadata::Val{M} = Val(false)) where {M}
363363
M ? zip(g.fadjlist[i], g.metadata[i]) : g.fadjlist[i]
364364
end
365365
function 𝑑neighbors(g::BipartiteGraph, j::Integer,
366-
with_metadata::Val{M} = Val(false)) where {M}
366+
with_metadata::Val{M} = Val(false)) where {M}
367367
require_complete(g)
368368
M ? zip(g.badjlist[j], (g.metadata[i][j] for i in g.badjlist[j])) : g.badjlist[j]
369369
end
@@ -389,7 +389,7 @@ Try to construct an augmenting path in matching and if such a path is found,
389389
update the matching accordingly.
390390
"""
391391
function construct_augmenting_path!(matching::Matching, g::BipartiteGraph, vsrc, dstfilter,
392-
dcolor = falses(ndsts(g)), scolor = nothing)
392+
dcolor = falses(ndsts(g)), scolor = nothing)
393393
scolor === nothing || (scolor[vsrc] = true)
394394

395395
# if a `vdst` is unassigned and the edge `vsrc <=> vdst` exists
@@ -421,7 +421,7 @@ vertices, subject to the constraint that vertices for which `srcfilter` or `dstf
421421
return `false` may not be matched.
422422
"""
423423
function maximal_matching(g::BipartiteGraph, srcfilter = vsrc -> true,
424-
dstfilter = vdst -> true, ::Type{U} = Unassigned) where {U}
424+
dstfilter = vdst -> true, ::Type{U} = Unassigned) where {U}
425425
matching = Matching{U}(ndsts(g))
426426
foreach(Iterators.filter(srcfilter, 𝑠vertices(g))) do vsrc
427427
construct_augmenting_path!(matching, g, vsrc, dstfilter)
@@ -550,7 +550,7 @@ Base.length(it::BipartiteEdgeIter) = ne(it.g)
550550
Base.eltype(it::BipartiteEdgeIter) = edgetype(it.g)
551551

552552
function Base.iterate(it::BipartiteEdgeIter{SRC, <:BipartiteGraph{T}},
553-
state = (1, 1, SRC)) where {T}
553+
state = (1, 1, SRC)) where {T}
554554
@unpack g = it
555555
neqs = nsrcs(g)
556556
neqs == 0 && return nothing
@@ -572,7 +572,7 @@ function Base.iterate(it::BipartiteEdgeIter{SRC, <:BipartiteGraph{T}},
572572
end
573573

574574
function Base.iterate(it::BipartiteEdgeIter{DST, <:BipartiteGraph{T}},
575-
state = (1, 1, DST)) where {T}
575+
state = (1, 1, DST)) where {T}
576576
@unpack g = it
577577
nvars = ndsts(g)
578578
nvars == 0 && return nothing
@@ -644,7 +644,7 @@ mutable struct DiCMOBiGraph{Transposed, I, G <: BipartiteGraph{I}, M <: Matching
644644
ne::Union{Missing, Int}
645645
matching::M
646646
function DiCMOBiGraph{Transposed}(g::G, ne::Union{Missing, Int},
647-
m::M) where {Transposed, I, G <: BipartiteGraph{I}, M}
647+
m::M) where {Transposed, I, G <: BipartiteGraph{I}, M}
648648
new{Transposed, I, G, M}(g, ne, m)
649649
end
650650
end
@@ -671,7 +671,7 @@ struct CMONeighbors{Transposed, V}
671671
g::DiCMOBiGraph{Transposed}
672672
v::V
673673
function CMONeighbors{Transposed}(g::DiCMOBiGraph{Transposed},
674-
v::V) where {Transposed, V}
674+
v::V) where {Transposed, V}
675675
new{Transposed, V}(g, v)
676676
end
677677
end

src/inputoutput.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ f[1](x, inputs, p, t)
192192
```
193193
"""
194194
function generate_control_function(sys::AbstractODESystem, inputs = unbound_inputs(sys),
195-
disturbance_inputs = disturbances(sys);
196-
implicit_dae = false,
197-
simplify = false,
198-
kwargs...)
195+
disturbance_inputs = disturbances(sys);
196+
implicit_dae = false,
197+
simplify = false,
198+
kwargs...)
199199
isempty(inputs) && @warn("No unbound inputs were found in system.")
200200

201201
if disturbance_inputs !== nothing

src/structural_transformation/bareiss.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ else
115115
end
116116

117117
function bareiss_update!(zero!, M::StridedMatrix, k, swapto, pivot,
118-
prev_pivot::Base.BitInteger)
118+
prev_pivot::Base.BitInteger)
119119
flag = zero(prev_pivot)
120120
prev_pivot = Base.MultiplicativeInverses.SignedMultiplicativeInverse(prev_pivot)
121121
@inbounds for i in (k + 1):size(M, 2)
@@ -149,7 +149,7 @@ end
149149
end
150150

151151
function bareiss_update_virtual_colswap!(zero!, M::AbstractMatrix, k, swapto, pivot,
152-
prev_pivot)
152+
prev_pivot)
153153
if prev_pivot isa Base.BitInteger
154154
prev_pivot = Base.MultiplicativeInverses.SignedMultiplicativeInverse(prev_pivot)
155155
end
@@ -189,7 +189,7 @@ bareiss_colswap (the default) swaps the columns and rows normally.
189189
bareiss_virtcolswap pretends to swap the columns which can be faster for sparse matrices.
190190
"""
191191
function bareiss!(M::AbstractMatrix{T}, swap_strategy = bareiss_colswap;
192-
find_pivot = find_pivot_any, column_pivots = nothing) where {T}
192+
find_pivot = find_pivot_any, column_pivots = nothing) where {T}
193193
swapcols!, swaprows!, update!, zero! = swap_strategy
194194
prev = one(eltype(M))
195195
n = size(M, 1)
@@ -252,7 +252,7 @@ end
252252
###
253253
### https://github.com/Nemocas/AbstractAlgebra.jl/blob/4803548c7a945f3f7bd8c63f8bb7c79fac92b11a/LICENSE.md
254254
function reduce_echelon!(A::AbstractMatrix{T}, rank, d,
255-
pivots_cache = zeros(Int, size(A, 2))) where {T}
255+
pivots_cache = zeros(Int, size(A, 2))) where {T}
256256
m, n = size(A)
257257
isreduced = true
258258
@inbounds for i in 1:rank
@@ -318,7 +318,7 @@ function reduce_echelon!(A::AbstractMatrix{T}, rank, d,
318318
end
319319

320320
function reduced_echelon_nullspace(rank, A::AbstractMatrix{T},
321-
pivots_cache = zeros(Int, size(A, 2))) where {T}
321+
pivots_cache = zeros(Int, size(A, 2))) where {T}
322322
n = size(A, 2)
323323
nullity = n - rank
324324
U = zeros(T, n, nullity)

src/structural_transformation/bipartite_tearing/modia_tearing.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function try_assign_eq!(ict::IncrementalCycleTracker, vj::Integer, eq::Integer)
1010
end
1111

1212
function try_assign_eq!(ict::IncrementalCycleTracker, vars, v_active, eq::Integer,
13-
condition::F = _ -> true) where {F}
13+
condition::F = _ -> true) where {F}
1414
G = ict.graph
1515
for vj in vars
1616
(vj in v_active && G.matching[vj] === unassigned && condition(vj)) || continue
@@ -20,7 +20,7 @@ function try_assign_eq!(ict::IncrementalCycleTracker, vars, v_active, eq::Intege
2020
end
2121

2222
function tearEquations!(ict::IncrementalCycleTracker, Gsolvable, es::Vector{Int},
23-
v_active::BitSet, isder′::F) where {F}
23+
v_active::BitSet, isder′::F) where {F}
2424
check_der = isder′ !== nothing
2525
if check_der
2626
has_der = Ref(false)
@@ -54,7 +54,7 @@ function tearEquations!(ict::IncrementalCycleTracker, Gsolvable, es::Vector{Int}
5454
end
5555

5656
function tear_graph_block_modia!(var_eq_matching, ict, solvable_graph, eqs, vars,
57-
isder::F) where {F}
57+
isder::F) where {F}
5858
tearEquations!(ict, solvable_graph.fadjlist, eqs, vars, isder)
5959
for var in vars
6060
var_eq_matching[var] = ict.graph.matching[var]
@@ -63,9 +63,9 @@ function tear_graph_block_modia!(var_eq_matching, ict, solvable_graph, eqs, vars
6363
end
6464

6565
function tear_graph_modia(structure::SystemStructure, isder::F = nothing,
66-
::Type{U} = Unassigned;
67-
varfilter::F2 = v -> true,
68-
eqfilter::F3 = eq -> true) where {F, U, F2, F3}
66+
::Type{U} = Unassigned;
67+
varfilter::F2 = v -> true,
68+
eqfilter::F3 = eq -> true) where {F, U, F2, F3}
6969
# It would be possible here to simply iterate over all variables and attempt to
7070
# use tearEquations! to produce a matching that greedily selects the minimal
7171
# number of torn variables. However, we can do this process faster if we first

src/structural_transformation/codegen.jl

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using ModelingToolkit: isdifferenceeq, process_events, get_preprocess_constants
55
const MAX_INLINE_NLSOLVE_SIZE = 8
66

77
function torn_system_with_nlsolve_jacobian_sparsity(state, var_eq_matching, var_sccs,
8-
nlsolve_scc_idxs, eqs_idxs, states_idxs)
8+
nlsolve_scc_idxs, eqs_idxs, states_idxs)
99
graph = state.structure.graph
1010

1111
# The sparsity pattern of `nlsolve(f, u, p)` w.r.t `p` is difficult to
@@ -97,7 +97,7 @@ function torn_system_with_nlsolve_jacobian_sparsity(state, var_eq_matching, var_
9797
end
9898

9999
function gen_nlsolve!(is_not_prepended_assignment, eqs, vars, u0map::AbstractDict,
100-
assignments, (deps, invdeps), var2assignment; checkbounds = true)
100+
assignments, (deps, invdeps), var2assignment; checkbounds = true)
101101
isempty(vars) && throw(ArgumentError("vars may not be empty"))
102102
length(eqs) == length(vars) ||
103103
throw(ArgumentError("vars must be of the same length as the number of equations to find the roots of"))
@@ -226,11 +226,11 @@ function gen_nlsolve!(is_not_prepended_assignment, eqs, vars, u0map::AbstractDic
226226
end
227227

228228
function build_torn_function(sys;
229-
expression = false,
230-
jacobian_sparsity = true,
231-
checkbounds = false,
232-
max_inlining_size = nothing,
233-
kw...)
229+
expression = false,
230+
jacobian_sparsity = true,
231+
checkbounds = false,
232+
max_inlining_size = nothing,
233+
kw...)
234234
max_inlining_size = something(max_inlining_size, MAX_INLINE_NLSOLVE_SIZE)
235235
rhss = []
236236
eqs = equations(sys)
@@ -382,14 +382,14 @@ function find_solve_sequence(sccs, vars)
382382
end
383383

384384
function build_observed_function(state, ts, var_eq_matching, var_sccs,
385-
is_solver_state_idxs,
386-
assignments,
387-
deps,
388-
sol_states,
389-
var2assignment;
390-
expression = false,
391-
output_type = Array,
392-
checkbounds = true)
385+
is_solver_state_idxs,
386+
assignments,
387+
deps,
388+
sol_states,
389+
var2assignment;
390+
expression = false,
391+
output_type = Array,
392+
checkbounds = true)
393393
is_not_prepended_assignment = trues(length(assignments))
394394
if (isscalar = !(ts isa AbstractVector))
395395
ts = [ts]
@@ -524,14 +524,14 @@ struct ODAEProblem{iip} end
524524
ODAEProblem(args...; kw...) = ODAEProblem{true}(args...; kw...)
525525

526526
function ODAEProblem{iip}(sys,
527-
u0map,
528-
tspan,
529-
parammap = DiffEqBase.NullParameters();
530-
callback = nothing,
531-
use_union = true,
532-
tofloat = true,
533-
check = true,
534-
kwargs...) where {iip}
527+
u0map,
528+
tspan,
529+
parammap = DiffEqBase.NullParameters();
530+
callback = nothing,
531+
use_union = true,
532+
tofloat = true,
533+
check = true,
534+
kwargs...) where {iip}
535535
eqs = equations(sys)
536536
check && ModelingToolkit.check_operator_variables(eqs, Differential)
537537
fun, dvs = build_torn_function(sys; kwargs...)

src/structural_transformation/partial_state_selection.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function ascend_dg_all(xs, dg, level, maxlevel)
2828
end
2929

3030
function pss_graph_modia!(structure::SystemStructure, maximal_top_matching, varlevel,
31-
inv_varlevel, inv_eqlevel)
31+
inv_varlevel, inv_eqlevel)
3232
@unpack eq_to_diff, var_to_diff, graph, solvable_graph = structure
3333

3434
# var_eq_matching is a maximal matching on the top-differentiated variables.
@@ -168,15 +168,15 @@ function partial_state_selection_graph!(structure::SystemStructure, var_eq_match
168168
end
169169

170170
function dummy_derivative_graph!(state::TransformationState, jac = nothing;
171-
state_priority = nothing, log = Val(false), kwargs...)
171+
state_priority = nothing, log = Val(false), kwargs...)
172172
state.structure.solvable_graph === nothing && find_solvables!(state; kwargs...)
173173
complete!(state.structure)
174174
var_eq_matching = complete(pantelides!(state))
175175
dummy_derivative_graph!(state.structure, var_eq_matching, jac, state_priority, log)
176176
end
177177

178178
function dummy_derivative_graph!(structure::SystemStructure, var_eq_matching, jac = nothing,
179-
state_priority = nothing, ::Val{log} = Val(false)) where {log}
179+
state_priority = nothing, ::Val{log} = Val(false)) where {log}
180180
@unpack eq_to_diff, var_to_diff, graph = structure
181181
diff_to_eq = invview(eq_to_diff)
182182
diff_to_var = invview(var_to_diff)

src/structural_transformation/symbolics_tearing.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function solve_equation(eq, var, simplify)
138138
end
139139

140140
function substitute_vars!(structure, subs, cache = Int[], callback! = nothing;
141-
exclude = ())
141+
exclude = ())
142142
@unpack graph, solvable_graph = structure
143143
for su in subs
144144
su === nothing && continue
@@ -163,7 +163,7 @@ function substitute_vars!(structure, subs, cache = Int[], callback! = nothing;
163163
end
164164

165165
function to_mass_matrix_form(neweqs, ieq, graph, fullvars, isdervar::F,
166-
var_to_diff) where {F}
166+
var_to_diff) where {F}
167167
eq = neweqs[ieq]
168168
if !(eq.lhs isa Number && eq.lhs == 0)
169169
eq = 0 ~ eq.rhs - eq.lhs
@@ -218,7 +218,7 @@ end
218218
=#
219219

220220
function tearing_reassemble(state::TearingState, var_eq_matching;
221-
simplify = false, mm = nothing)
221+
simplify = false, mm = nothing)
222222
@unpack fullvars, sys, structure = state
223223
@unpack solvable_graph, var_to_diff, eq_to_diff, graph = structure
224224

@@ -584,7 +584,7 @@ new residual equations after tearing. End users are encouraged to call [`structu
584584
instead, which calls this function internally.
585585
"""
586586
function tearing(sys::AbstractSystem, state = TearingState(sys); mm = nothing,
587-
simplify = false, kwargs...)
587+
simplify = false, kwargs...)
588588
var_eq_matching = tearing(state)
589589
invalidate_cache!(tearing_reassemble(state, var_eq_matching; mm, simplify))
590590
end
@@ -608,7 +608,7 @@ Perform index reduction and use the dummy derivative technique to ensure that
608608
the system is balanced.
609609
"""
610610
function dummy_derivative(sys, state = TearingState(sys); simplify = false,
611-
mm = nothing, kwargs...)
611+
mm = nothing, kwargs...)
612612
jac = let state = state
613613
(eqs, vars) -> begin
614614
symeqs = EquationsView(state)[eqs]

0 commit comments

Comments
 (0)