Skip to content

Commit 4da98a0

Browse files
authored
Merge pull request #306 from control-toolbox/auto-juliaformatter-pr
[AUTO] JuliaFormatter.jl run
2 parents 9555669 + 95034a7 commit 4da98a0

12 files changed

Lines changed: 58 additions & 74 deletions

File tree

src/CTModels.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ using .Serialization
9191
include(joinpath(@__DIR__, "Init", "Init.jl"))
9292
using .Init
9393

94-
end
94+
end

src/Display/definition.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ Display method for any [`AbstractDefinition`](@ref).
4444
4545
Delegates to [`_print_abstract_definition`](@ref).
4646
"""
47-
Base.show(io::IO, ::MIME"text/plain", d::AbstractDefinition) =
47+
function Base.show(io::IO, ::MIME"text/plain", d::AbstractDefinition)
4848
_print_abstract_definition(io, d)
49+
end

src/OCP/Building/model.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,14 @@ function _dedup_box_constraints!(
136136

137137
# sort by component index for readability
138138
perm = sortperm(new_inds)
139-
resize!(inds, length(new_inds)); inds .= new_inds[perm]
140-
resize!(lbs, length(new_lbs)); lbs .= new_lbs[perm]
141-
resize!(ubs, length(new_ubs)); ubs .= new_ubs[perm]
142-
resize!(labels, length(new_labels)); labels .= new_labels[perm]
139+
resize!(inds, length(new_inds));
140+
inds .= new_inds[perm]
141+
resize!(lbs, length(new_lbs));
142+
lbs .= new_lbs[perm]
143+
resize!(ubs, length(new_ubs));
144+
ubs .= new_ubs[perm]
145+
resize!(labels, length(new_labels));
146+
labels .= new_labels[perm]
143147
empty!(aliases)
144148
append!(aliases, new_aliases[perm])
145149
return nothing

src/OCP/Building/solution.jl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,16 +1338,10 @@ function Base.show(io::IO, ::MIME"text/plain", sol::Solution)
13381338
if variable_dimension(sol) > 0
13391339
components = variable_components(sol)
13401340
var_name = variable_name(sol)
1341-
1341+
13421342
# Simplified case: dimension 1 and name identical
13431343
if variable_dimension(sol) == 1 && var_name == components[1]
1344-
println(
1345-
io,
1346-
"\n• Variable: ",
1347-
var_name,
1348-
" = ",
1349-
variable(sol),
1350-
)
1344+
println(io, "\n• Variable: ", var_name, " = ", variable(sol))
13511345
else
13521346
println(
13531347
io,
@@ -1359,7 +1353,8 @@ function Base.show(io::IO, ::MIME"text/plain", sol::Solution)
13591353
variable(sol),
13601354
)
13611355
end
1362-
if dim_dual_variable_constraints_box(sol) > 0 && dim_variable_constraints_box(model(sol)) > 0
1356+
if dim_dual_variable_constraints_box(sol) > 0 &&
1357+
dim_variable_constraints_box(model(sol)) > 0
13631358
println(io, " │ Var dual (lb) : ", variable_constraints_lb_dual(sol))
13641359
println(io, " └─ Var dual (ub) : ", variable_constraints_ub_dual(sol))
13651360
end

src/OCP/Components/definition.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ Since no symbolic definition was attached, the canonical empty expression
6464
6565
- `Expr`: An empty block expression `:(begin end)`.
6666
"""
67-
expression(::EmptyDefinition)::Expr = :(begin end)
67+
expression(::EmptyDefinition)::Expr = :(
68+
begin end
69+
)
6870

6971
"""
7072
$(TYPEDSIGNATURES)

src/OCP/OCP.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ export path_constraints_nl, boundary_constraints_nl
125125
export state_constraints_box, control_constraints_box, variable_constraints_box
126126
export dim_path_constraints_nl, dim_boundary_constraints_nl
127127
export dim_state_constraints_box, dim_control_constraints_box, dim_variable_constraints_box
128-
export dim_dual_state_constraints_box, dim_dual_control_constraints_box, dim_dual_variable_constraints_box
128+
export dim_dual_state_constraints_box,
129+
dim_dual_control_constraints_box, dim_dual_variable_constraints_box
129130
export state, control, variable, costate, objective
130131
export dynamics, mayer, lagrange
131132
export definition, expression, dual

src/OCP/Types/model.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ struct Model{
107107
end
108108
end
109109

110-
111110
"""
112111
$(TYPEDEF)
113112

test/suite/display/test_print.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@ function test_print()
2929

3030
Test.@testset "_print_abstract_definition returns false for EmptyDefinition" begin
3131
io = IOBuffer()
32-
result = CTModels.Display._print_abstract_definition(io, CTModels.EmptyDefinition())
32+
result = CTModels.Display._print_abstract_definition(
33+
io, CTModels.EmptyDefinition()
34+
)
3335
Test.@test result == false
3436
Test.@test isempty(String(take!(io)))
3537
end
3638

3739
Test.@testset "_print_abstract_definition returns true for Definition" begin
3840
io = IOBuffer()
39-
result = CTModels.Display._print_abstract_definition(io, CTModels.Definition(:(x = 1)))
41+
result = CTModels.Display._print_abstract_definition(
42+
io, CTModels.Definition(:(x = 1))
43+
)
4044
Test.@test result == true
4145
Test.@test occursin("Abstract definition:", String(take!(io)))
4246
end
@@ -126,7 +130,9 @@ function test_print()
126130
CTModels.variable!(pre, 0)
127131
dyn!(r, t, x, u, v) = r .= 0
128132
CTModels.dynamics!(pre, dyn!)
129-
CTModels.objective!(pre, :min; mayer=(x0, xf, v) -> 0.0, lagrange=(t, x, u, v) -> 0.0)
133+
CTModels.objective!(
134+
pre, :min; mayer=(x0, xf, v) -> 0.0, lagrange=(t, x, u, v) -> 0.0
135+
)
130136
CTModels.time_dependence!(pre; autonomous=false)
131137

132138
model = CTModels.build(pre)
@@ -149,7 +155,9 @@ function test_print()
149155
CTModels.variable!(pre, 0)
150156
dyn!(r, t, x, u, v) = r .= 0
151157
CTModels.dynamics!(pre, dyn!)
152-
CTModels.objective!(pre, :min; mayer=(x0, xf, v) -> 0.0, lagrange=(t, x, u, v) -> 0.0)
158+
CTModels.objective!(
159+
pre, :min; mayer=(x0, xf, v) -> 0.0, lagrange=(t, x, u, v) -> 0.0
160+
)
153161
CTModels.time_dependence!(pre; autonomous=false)
154162

155163
io = IOBuffer()

test/suite/ocp/test_constraints.jl

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,7 @@ function test_constraints()
290290
Test.@testset "single full-range declaration preserves order" begin
291291
ocp = _make_min_premodel(; state_dim=3)
292292
CTModels.constraint!(
293-
ocp,
294-
:state;
295-
rg=1:3,
296-
lb=[0.0, 1.0, 2.0],
297-
ub=[1.0, 2.0, 3.0],
298-
label=:s,
293+
ocp, :state; rg=1:3, lb=[0.0, 1.0, 2.0], ub=[1.0, 2.0, 3.0], label=:s
299294
)
300295
m = CTModels.build(ocp)
301296
cs = CTModels.state_constraints_box(m)
@@ -323,12 +318,8 @@ function test_constraints()
323318

324319
Test.@testset "duplicate: intersection applied, per-component uniqueness" begin
325320
ocp = _make_min_premodel(; state_dim=2)
326-
CTModels.constraint!(
327-
ocp, :state; rg=1:1, lb=[0.0], ub=[2.0], label=:s1
328-
)
329-
CTModels.constraint!(
330-
ocp, :state; rg=1:1, lb=[0.5], ub=[1.5], label=:s2
331-
)
321+
CTModels.constraint!(ocp, :state; rg=1:1, lb=[0.0], ub=[2.0], label=:s1)
322+
CTModels.constraint!(ocp, :state; rg=1:1, lb=[0.5], ub=[1.5], label=:s2)
332323
# warning emitted once at build; storage holds one entry per component
333324
m = (Test.@test_logs (:warn, r"Multiple bound declarations") CTModels.build(
334325
ocp
@@ -348,20 +339,10 @@ function test_constraints()
348339
Test.@testset "overlapping ranges" begin
349340
ocp = _make_min_premodel(; state_dim=3)
350341
CTModels.constraint!(
351-
ocp,
352-
:state;
353-
rg=1:2,
354-
lb=[0.0, 1.0],
355-
ub=[1.0, 2.0],
356-
label=:a,
342+
ocp, :state; rg=1:2, lb=[0.0, 1.0], ub=[1.0, 2.0], label=:a
357343
)
358344
CTModels.constraint!(
359-
ocp,
360-
:state;
361-
rg=2:3,
362-
lb=[0.5, 1.5],
363-
ub=[1.5, 2.5],
364-
label=:b,
345+
ocp, :state; rg=2:3, lb=[0.5, 1.5], ub=[1.5, 2.5], label=:b
365346
)
366347
m = (Test.@test_logs (:warn, r"component 2") CTModels.build(ocp))
367348
cs = CTModels.state_constraints_box(m)

test/suite/ocp/test_definition.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ function test_definition()
109109
CTModels.variable!(pre, 0)
110110
dyn!(r, t, x, u, v) = r .= 0
111111
CTModels.dynamics!(pre, dyn!)
112-
CTModels.objective!(pre, :min; mayer=(x0, xf, v) -> 0.0, lagrange=(t, x, u, v) -> 0.0)
112+
CTModels.objective!(
113+
pre, :min; mayer=(x0, xf, v) -> 0.0, lagrange=(t, x, u, v) -> 0.0
114+
)
113115
CTModels.time_dependence!(pre; autonomous=false)
114116

115117
model = CTModels.build(pre)
@@ -127,7 +129,9 @@ function test_definition()
127129
CTModels.variable!(pre, 0)
128130
dyn!(r, t, x, u, v) = r .= 0
129131
CTModels.dynamics!(pre, dyn!)
130-
CTModels.objective!(pre, :min; mayer=(x0, xf, v) -> 0.0, lagrange=(t, x, u, v) -> 0.0)
132+
CTModels.objective!(
133+
pre, :min; mayer=(x0, xf, v) -> 0.0, lagrange=(t, x, u, v) -> 0.0
134+
)
131135
expr = quote
132136
t [0, 1], time
133137
x R, state

0 commit comments

Comments
 (0)