Skip to content

Commit 6cd1858

Browse files
authored
Merge pull request #68 from control-toolbox/auto-juliaformatter-pr
[AUTO] JuliaFormatter.jl run
2 parents b5308b7 + d7555b1 commit 6cd1858

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

src/solution.jl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ function build_solution(
5656
control_constraints_ub_dual::Matrix{Float64}=zeros(0, 0),
5757
variable_constraints_lb_dual::Vector{Float64}=zeros(0),
5858
variable_constraints_ub_dual::Vector{Float64}=zeros(0),
59-
) where {
60-
TX <: Union{Matrix{Float64}, Function},
61-
TU <: Union{Matrix{Float64}, Function},
62-
TP <: Union{Matrix{Float64}, Function},
63-
}
59+
) where {
60+
TX<:Union{Matrix{Float64},Function},
61+
TU<:Union{Matrix{Float64},Function},
62+
TP<:Union{Matrix{Float64},Function},
63+
}
6464

6565
# get dimensions
6666
dim_x = state_dimension(ocp)
@@ -80,8 +80,13 @@ function build_solution(
8080

8181
# variables: remove additional state for lagrange objective
8282
x = TX <: Function ? X : ctinterpolate(T, matrix2vec(X[:, 1:dim_x], 1))
83-
p = TU <: Function ? P :
84-
length(T) == 2 ? t -> P[1, 1:dim_x] : ctinterpolate(T[1:(end - 1)], matrix2vec(P[:, 1:dim_x], 1))
83+
p = if TU <: Function
84+
P
85+
elseif length(T) == 2
86+
t -> P[1, 1:dim_x]
87+
else
88+
ctinterpolate(T[1:(end - 1)], matrix2vec(P[:, 1:dim_x], 1))
89+
end
8590
u = TP <: Function ? U : ctinterpolate(T, matrix2vec(U[:, 1:dim_u], 1))
8691

8792
# force scalar output when dimension is 1

test/extras/plot_manual.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using CTModels
22
using Plots
33

4-
FUN=true
4+
FUN = true
55

66
# create a pre-model
77
pre_ocp = CTModels.PreModel()

test/solution_example.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function solution_example(;fun=false)
1+
function solution_example(; fun=false)
22

33
# create a pre-model
44
pre_ocp = CTModels.PreModel()

test/test_export_import.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function test_export_import()
1818
@test sol.objective == sol_reloaded.objective
1919

2020
#
21-
ocp, sol = solution_example(fun=true)
21+
ocp, sol = solution_example(; fun=true)
2222

2323
# JSON
2424
CTModels.export_ocp_solution(sol; filename_prefix="solution_test", format=:JSON)
@@ -33,5 +33,4 @@ function test_export_import()
3333
ocp; filename_prefix="solution_test", format=:JLD
3434
)
3535
@test sol.objective == sol_reloaded.objective
36-
3736
end

0 commit comments

Comments
 (0)