Skip to content

Commit f2bd23f

Browse files
Revert "run JuliaFormatter per contributing guidelines. I didn't touch any of these files except ext/MTKFMIExt.jl!"
This reverts commit 37c6897.
1 parent 37c6897 commit f2bd23f

File tree

10 files changed

+53
-60
lines changed

10 files changed

+53
-60
lines changed

docs/src/internals.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ This section documents the internal implementation details of ModelingToolkit. T
66

77
ModelingToolkit's internal architecture consists of several key components:
88

9-
- **Structural Transformation**: Algorithms for transforming equation systems, including index reduction, tearing, and algebraic simplification
10-
- **Bipartite Graphs**: Graph representations used to analyze relationships between equations and variables
11-
- **System Structure**: Internal representations of system state and transformations
9+
- **Structural Transformation**: Algorithms for transforming equation systems, including index reduction, tearing, and algebraic simplification
10+
- **Bipartite Graphs**: Graph representations used to analyze relationships between equations and variables
11+
- **System Structure**: Internal representations of system state and transformations
1212

1313
These components work together to enable ModelingToolkit's symbolic manipulation and code generation capabilities.
1414

1515
!!! warning
16-
1716
The functions and types documented in this section are internal implementation details. Users should not rely on these APIs as they may change or be removed without deprecation warnings.

docs/src/internals/bipartite_graph.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Bipartite Graphs
22

33
!!! warning "Internal API"
4-
54
The functions documented on this page are internal implementation details of ModelingToolkit. They are not part of the public API and may change or be removed without notice in non-breaking releases. This documentation is provided to help contributors understand the codebase.
65

76
ModelingToolkit uses bipartite graphs to represent relationships between equations and variables in systems. These functions provide tools for working with and analyzing these graphs.
@@ -78,4 +77,4 @@ asdigraph
7877
```@docs
7978
SRC
8079
DST
81-
```
80+
```

docs/src/internals/structural_transformation.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Structural Transformation
22

33
!!! warning "Internal API"
4-
54
The functions documented on this page are internal implementation details of ModelingToolkit. They are not part of the public API and may change or be removed without notice in non-breaking releases. This documentation is provided to help contributors understand the codebase.
65

76
These functions are used for structural analysis and transformation of equation systems, including index reduction, tearing, and other algebraic manipulations used in the simplification process.
@@ -85,4 +84,4 @@ InducedCondensationGraph
8584
MatchedCondensationGraph
8685
Unassigned
8786
unassigned
88-
```
87+
```

ext/MTKFMIExt.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,13 @@ function parseFMIVariableName(name::AbstractString)
373373
safe_name = name
374374
end
375375

376+
376377
idx = findfirst(',', safe_name)
377378
if idx === nothing
378379
name = @view name[5:(end - 1)]
379380
der = 1
380381
else
382+
381383
der = parse(Int, @view name[(idx + 1):(end - 1)])
382384
name = @view name[5:(idx - 1)]
383385
end

src/systems/diffeqs/basic_transformations.jl

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,14 @@ sol = solve(prob, radau5(), abstol = 1e-10, reltol = 1e-10)
207207
"""
208208
function fractional_to_ordinary(
209209
eqs, variables, alphas, epsilon, T;
210-
initials = 0, additional_eqs = [], iv = only(@independent_variables t), matrix = false
210+
initials = 0, additional_eqs = [], iv = only(@independent_variables t), matrix=false
211211
)
212212
D = Differential(iv)
213213
i = 0
214214
all_eqs = Equation[]
215215
all_def = Pair[]
216-
217-
function fto_helper(sub_eq, sub_var, α; initial = 0)
216+
217+
function fto_helper(sub_eq, sub_var, α; initial=0)
218218
alpha_0 = α
219219

220220
if> 1)
@@ -250,30 +250,28 @@ function fractional_to_ordinary(
250250
if matrix
251251
new_z = Symbol(, :_, i)
252252
i += 1
253-
γs = diagm([γ_i(index) for index in M:(N - 1)])
254-
cs = [c_i(index) for index in M:(N - 1)]
253+
γs = diagm([γ_i(index) for index in M:N-1])
254+
cs = [c_i(index) for index in M:N-1]
255255

256256
if< 1)
257-
new_z = only(@variables $new_z(iv)[1:(N - M)])
257+
new_z = only(@variables $new_z(iv)[1:N-M])
258258
new_eq = D(new_z) ~ -γs*new_z .+ sub_eq
259259
rhs = dot(cs, new_z) + initial
260260
push!(def, new_z=>zeros(N-M))
261261
else
262-
new_z = only(@variables $new_z(iv)[1:(N - M), 1:m])
263-
new_eq = D(new_z) ~
264-
-γs*new_z +
265-
hcat(fill(sub_eq, N-M, 1), collect(new_z[:, 1:(m - 1)]*diagm(1:(m - 1))))
266-
rhs = coeff*sum(cs[i]*new_z[i, m] for i in 1:(N - M))
262+
new_z = only(@variables $new_z(iv)[1:N-M, 1:m])
263+
new_eq = D(new_z) ~ -γs*new_z + hcat(fill(sub_eq, N-M, 1), collect(new_z[:, 1:m-1]*diagm(1:m-1)))
264+
rhs = coeff*sum(cs[i]*new_z[i, m] for i in 1:N-M)
267265
for (index, value) in enumerate(initial)
268266
rhs += value * iv^(index - 1) / gamma(index)
269267
end
270268
push!(def, new_z=>zeros(N-M, m))
271269
end
272270
push!(new_eqs, new_eq)
273271
else
274-
if< 1)
272+
if< 1)
275273
rhs = initial
276-
for index in range(M, N-1; step = 1)
274+
for index in range(M, N-1; step=1)
277275
new_z = Symbol(, :_, i)
278276
i += 1
279277
new_z = ModelingToolkit.unwrap(only(@variables $new_z(iv)))
@@ -287,12 +285,12 @@ function fractional_to_ordinary(
287285
for (index, value) in enumerate(initial)
288286
rhs += value * iv^(index - 1) / gamma(index)
289287
end
290-
for index in range(M, N-1; step = 1)
288+
for index in range(M, N-1; step=1)
291289
new_z = Symbol(, :_, i)
292290
i += 1
293291
γ = γ_i(index)
294292
base = sub_eq
295-
for k in range(1, m; step = 1)
293+
for k in range(1, m; step=1)
296294
new_z = Symbol(, :_, index-M, :_, k)
297295
new_z = ModelingToolkit.unwrap(only(@variables $new_z(iv)))
298296
new_eq = D(new_z) ~ base - γ*new_z
@@ -309,12 +307,12 @@ function fractional_to_ordinary(
309307
end
310308

311309
for (eq, cur_var, alpha, init) in zip(eqs, variables, alphas, initials)
312-
(new_eqs, def) = fto_helper(eq, cur_var, alpha; initial = init)
310+
(new_eqs, def) = fto_helper(eq, cur_var, alpha; initial=init)
313311
append!(all_eqs, new_eqs)
314312
append!(all_def, def)
315313
end
316314
append!(all_eqs, additional_eqs)
317-
@named sys = System(all_eqs, iv; defaults = all_def)
315+
@named sys = System(all_eqs, iv; defaults=all_def)
318316
return mtkcompile(sys)
319317
end
320318

@@ -340,7 +338,7 @@ sol = solve(prob, radau5(), abstol = 1e-5, reltol = 1e-5)
340338
"""
341339
function linear_fractional_to_ordinary(
342340
degrees, coeffs, rhs, epsilon, T;
343-
initials = 0, symbol = :x, iv = only(@independent_variables t), matrix = false
341+
initials = 0, symbol = :x, iv = only(@independent_variables t), matrix=false
344342
)
345343
previous = Symbol(symbol, :_, 0)
346344
previous = ModelingToolkit.unwrap(only(@variables $previous(iv)))
@@ -373,17 +371,17 @@ function linear_fractional_to_ordinary(
373371
if matrix
374372
new_z = Symbol(, :_, i)
375373
i += 1
376-
γs = diagm([γ_i(index) for index in M:(N - 1)])
377-
cs = [c_i(index) for index in M:(N - 1)]
374+
γs = diagm([γ_i(index) for index in M:N-1])
375+
cs = [c_i(index) for index in M:N-1]
378376

379-
new_z = only(@variables $new_z(iv)[1:(N - M)])
377+
new_z = only(@variables $new_z(iv)[1:N-M])
380378
new_eq = D(new_z) ~ -γs*new_z .+ sub_eq
381379
sum = dot(cs, new_z)
382380
push!(def, new_z=>zeros(N-M))
383381
push!(new_eqs, new_eq)
384382
else
385383
sum = 0
386-
for index in range(M, N-1; step = 1)
384+
for index in range(M, N-1; step=1)
387385
new_z = Symbol(, :_, i)
388386
i += 1
389387
new_z = ModelingToolkit.unwrap(only(@variables $new_z(iv)))
@@ -396,7 +394,7 @@ function linear_fractional_to_ordinary(
396394
return (new_eqs, def, sum)
397395
end
398396

399-
for i in range(1, ceil(Int, degrees[1]); step = 1)
397+
for i in range(1, ceil(Int, degrees[1]); step=1)
400398
new_x = Symbol(symbol, :_, i)
401399
new_x = ModelingToolkit.unwrap(only(@variables $new_x(iv)))
402400
push!(all_eqs, D(previous) ~ new_x)
@@ -419,7 +417,7 @@ function linear_fractional_to_ordinary(
419417
end
420418
end
421419
push!(all_eqs, 0 ~ new_rhs)
422-
@named sys = System(all_eqs, iv; defaults = all_def)
420+
@named sys = System(all_eqs, iv; defaults=all_def)
423421
return mtkcompile(sys)
424422
end
425423

test/components.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,7 @@ end
352352
@named comp1 = System(Equation[], t; systems = [input])
353353
@named output = RealOutput()
354354
@named comp2 = System(Equation[], t; systems = [output])
355-
@named sys = System([connect(comp2.output.u, comp1.input.u)], t; systems = [
356-
comp1, comp2])
355+
@named sys = System([connect(comp2.output.u, comp1.input.u)], t; systems = [comp1, comp2])
357356
eq = only(equations(expand_connections(sys)))
358357
# as opposed to `output.u ~ input.u`
359358
@test isequal(eq, comp1.input.u ~ comp2.output.u)

test/fractional_to_ordinary.jl

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ using Test
66
@independent_variables t
77
@variables x(t)
88
D = Differential(t)
9-
tspan = (0.0, 1.0)
10-
timepoint = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
9+
tspan = (0., 1.)
10+
timepoint = [0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.]
1111

1212
function expect(t, α)
1313
return (3/2*t^/2) - t^4)^2
@@ -19,23 +19,23 @@ eqs += (gamma(9)*t^(8 - α)/gamma(9 - α)) + (3/2*t^(α/2)-t^4)^3 - x^(3/2)
1919
sys = fractional_to_ordinary(eqs, x, α, 10^-7, 1)
2020

2121
prob = ODEProblem(sys, [], tspan)
22-
sol = solve(prob, radau5(), saveat = timepoint, abstol = 1e-10, reltol = 1e-10)
22+
sol = solve(prob, radau5(), saveat=timepoint, abstol = 1e-10, reltol = 1e-10)
2323

2424
for time in 0:0.1:1
25-
@test isapprox(expect(time, α), sol(time, idxs = x), atol = 1e-7)
25+
@test isapprox(expect(time, α), sol(time, idxs=x), atol=1e-7)
2626
time += 0.1
2727
end
2828

2929
α = 0.3
3030
eqs = (9*gamma(1 + α)/4) - (3*t^(4 - α/2)*gamma(5 + α/2)/gamma(5 - α/2))
3131
eqs += (gamma(9)*t^(8 - α)/gamma(9 - α)) + (3/2*t^/2)-t^4)^3 - x^(3/2)
32-
sys = fractional_to_ordinary(eqs, x, α, 10^-7, 1; matrix = true)
32+
sys = fractional_to_ordinary(eqs, x, α, 10^-7, 1; matrix=true)
3333

3434
prob = ODEProblem(sys, [], tspan)
35-
sol = solve(prob, radau5(), saveat = timepoint, abstol = 1e-10, reltol = 1e-10)
35+
sol = solve(prob, radau5(), saveat=timepoint, abstol = 1e-10, reltol = 1e-10)
3636

3737
for time in 0:0.1:1
38-
@test isapprox(expect(time, α), sol(time, idxs = x), atol = 1e-7)
38+
@test isapprox(expect(time, α), sol(time, idxs=x), atol=1e-7)
3939
end
4040

4141
α = 0.9
@@ -44,46 +44,43 @@ eqs += (gamma(9)*t^(8 - α)/gamma(9 - α)) + (3/2*t^(α/2)-t^4)^3 - x^(3/2)
4444
sys = fractional_to_ordinary(eqs, x, α, 10^-7, 1)
4545

4646
prob = ODEProblem(sys, [], tspan)
47-
sol = solve(prob, radau5(), saveat = timepoint, abstol = 1e-10, reltol = 1e-10)
47+
sol = solve(prob, radau5(), saveat=timepoint, abstol = 1e-10, reltol = 1e-10)
4848

4949
for time in 0:0.1:1
50-
@test isapprox(expect(time, α), sol(time, idxs = x), atol = 1e-7)
50+
@test isapprox(expect(time, α), sol(time, idxs=x), atol=1e-7)
5151
end
5252

5353
# Testing for example 2 of Section 7
5454
@independent_variables t
5555
@variables x(t) y(t)
5656
D = Differential(t)
57-
tspan = (0.0, 220.0)
57+
tspan = (0., 220.)
5858

59-
sys = fractional_to_ordinary([1 - 4*x + x^2 * y, 3*x - x^2 * y], [x, y], [1.3, 0.8],
60-
10^-8, 220; initials = [[1.2, 1], 2.8], matrix = true)
59+
sys = fractional_to_ordinary([1 - 4*x + x^2 * y, 3*x - x^2 * y], [x, y], [1.3, 0.8], 10^-8, 220; initials=[[1.2, 1], 2.8], matrix=true)
6160
prob = ODEProblem(sys, [], tspan)
6261
sol = solve(prob, radau5(), abstol = 1e-8, reltol = 1e-8)
6362

64-
@test isapprox(1.0097684171, sol(220, idxs = x), atol = 1e-5)
65-
@test isapprox(2.1581264031, sol(220, idxs = y), atol = 1e-5)
63+
@test isapprox(1.0097684171, sol(220, idxs=x), atol=1e-5)
64+
@test isapprox(2.1581264031, sol(220, idxs=y), atol=1e-5)
6665

6766
#Testing for example 3 of Section 7
6867
@independent_variables t
6968
@variables x_0(t)
7069
D = Differential(t)
71-
tspan = (0.0, 5000.0)
70+
tspan = (0., 5000.)
7271

7372
function expect(t)
7473
return sqrt(2) * sin(t + pi/4)
7574
end
7675

77-
sys = linear_fractional_to_ordinary([3, 2.5, 2, 1, 0.5, 0], [1, 1, 1, 4, 1, 4],
78-
6*cos(t), 10^-5, 5000; initials = [1, 1, -1])
76+
sys = linear_fractional_to_ordinary([3, 2.5, 2, 1, .5, 0], [1, 1, 1, 4, 1, 4], 6*cos(t), 10^-5, 5000; initials=[1, 1, -1])
7977
prob = ODEProblem(sys, [], tspan)
8078
sol = solve(prob, radau5(), abstol = 1e-5, reltol = 1e-5)
8179

82-
@test isapprox(expect(5000), sol(5000, idxs = x_0), atol = 1e-5)
80+
@test isapprox(expect(5000), sol(5000, idxs=x_0), atol=1e-5)
8381

84-
msys = linear_fractional_to_ordinary([3, 2.5, 2, 1, 0.5, 0], [1, 1, 1, 4, 1, 4], 6*cos(t),
85-
10^-5, 5000; initials = [1, 1, -1], matrix = true)
82+
msys = linear_fractional_to_ordinary([3, 2.5, 2, 1, .5, 0], [1, 1, 1, 4, 1, 4], 6*cos(t), 10^-5, 5000; initials=[1, 1, -1], matrix=true)
8683
mprob = ODEProblem(sys, [], tspan)
8784
msol = solve(prob, radau5(), abstol = 1e-5, reltol = 1e-5)
8885

89-
@test isapprox(expect(5000), msol(5000, idxs = x_0), atol = 1e-5)
86+
@test isapprox(expect(5000), msol(5000, idxs=x_0), atol=1e-5)

test/model_parsing.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,16 +1065,16 @@ end
10651065
MyBool => false
10661066
NewInt => 1
10671067
end
1068-
1068+
10691069
@parameters begin
10701070
k = 1.0
10711071
end
1072-
1072+
10731073
@variables begin
10741074
x(t)
10751075
y(t)
10761076
end
1077-
1077+
10781078
@equations begin
10791079
D(x) ~ -k * x
10801080
y ~ x

test/parameter_dependencies.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ end
174174
end
175175

176176
@testset "Change Tunables" begin
177-
@variables θ(t)=π/6 ω(t)=0.0
177+
@variables θ(t)=π/6 ω(t)=0.
178178
@parameters g=9.81 L=1.0 b=0.1 errp=1
179179
eqs = [
180180
D(θ) ~ ω,

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ end
103103
@safetestset "Fractional Differential Equations Tests" include("fractional_to_ordinary.jl")
104104
end
105105
end
106-
106+
107107
if GROUP == "All" || GROUP == "SymbolicIndexingInterface"
108108
@safetestset "SymbolicIndexingInterface test" include("symbolic_indexing_interface.jl")
109109
@safetestset "SciML Problem Input Test" include("sciml_problem_inputs.jl")

0 commit comments

Comments
 (0)