Skip to content

Commit 65d4f62

Browse files
authored
Merge pull request #297 from control-toolbox/auto-juliaformatter-pr
[AUTO] JuliaFormatter.jl run
2 parents 0033751 + 4348236 commit 65d4f62

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

src/OCP/Building/solution.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ function build_solution(
244244
T_path = isnothing(T_path) ? nothing : _validate_and_fix_time_grid(T_path, "path")
245245

246246
# NEW: Extend grids that are prefixes of the longest grid to enable UnifiedTimeGridModel
247-
non_nothing_grids_initial = filter(g -> !isnothing(g), [T_state, T_control, T_costate, T_path])
247+
non_nothing_grids_initial = filter(
248+
g -> !isnothing(g), [T_state, T_control, T_costate, T_path]
249+
)
248250
if length(non_nothing_grids_initial) > 1
249251
# Find the longest grid as reference
250252
T_ref = non_nothing_grids_initial[argmax(map(length, non_nothing_grids_initial))]
@@ -428,9 +430,7 @@ grid unification. Otherwise, it returns `T_target` unchanged.
428430
See also: [`_validate_and_fix_time_grid`](@ref), [`build_solution`](@ref)
429431
"""
430432
function _extend_grid_to_match(
431-
T_target::Vector{Float64},
432-
T_reference::Vector{Float64},
433-
component_name::String,
433+
T_target::Vector{Float64}, T_reference::Vector{Float64}, component_name::String
434434
)::Vector{Float64}
435435
# Check if T_target is a strict prefix of T_reference (missing only last element)
436436
if length(T_target) == length(T_reference) - 1 && T_target == T_reference[1:(end - 1)]

test/suite/ocp/test_grid_extension.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TestGridExtension
22

3-
import Test
3+
using Test: Test
44
import CTBase.Exceptions
55
import CTModels.OCP
66

@@ -61,7 +61,9 @@ function test_grid_extension()
6161
T_path = nothing
6262

6363
# Apply extension logic (mimicking build_solution internal logic)
64-
non_nothing_grids = filter(g -> !isnothing(g), [T_state, T_control, T_costate, T_path])
64+
non_nothing_grids = filter(
65+
g -> !isnothing(g), [T_state, T_control, T_costate, T_path]
66+
)
6567
T_ref = non_nothing_grids[argmax(map(length, non_nothing_grids))]
6668
T_control_extended = OCP._extend_grid_to_match(T_control, T_ref, "control")
6769
T_costate_extended = OCP._extend_grid_to_match(T_costate, T_ref, "costate")
@@ -72,11 +74,15 @@ function test_grid_extension()
7274
Test.@test T_state == T_ref
7375

7476
# This would enable UnifiedTimeGridModel in build_solution
75-
non_nothing_grids_extended = filter(g -> !isnothing(g), [T_state, T_control_extended, T_costate_extended, T_path])
76-
all_identical = all(g -> g == first(non_nothing_grids_extended), non_nothing_grids_extended)
77+
non_nothing_grids_extended = filter(
78+
g -> !isnothing(g),
79+
[T_state, T_control_extended, T_costate_extended, T_path],
80+
)
81+
all_identical = all(
82+
g -> g == first(non_nothing_grids_extended), non_nothing_grids_extended
83+
)
7784
Test.@test all_identical
7885
end
79-
8086
end
8187
end
8288

0 commit comments

Comments
 (0)