Skip to content

Commit 7a5c41d

Browse files
committed
Merge branch 'main' of github.com:control-toolbox/CTBase.jl
2 parents 1906e2e + 45323c4 commit 7a5c41d

9 files changed

Lines changed: 58 additions & 63 deletions

File tree

src/Data/hamiltonian.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ Hamiltonian: non-autonomous, fixed (no variable)
5858
5959
See also: [`CTBase.Data.AbstractHamiltonian`](@ref), [`CTBase.Traits.TimeDependence`](@ref), [`CTBase.Traits.VariableDependence`](@ref).
6060
"""
61-
struct Hamiltonian{
62-
F<:Function,TD<:Traits.TimeDependence,VD<:Traits.VariableDependence
63-
} <: AbstractHamiltonian{TD,VD}
61+
struct Hamiltonian{F<:Function,TD<:Traits.TimeDependence,VD<:Traits.VariableDependence} <:
62+
AbstractHamiltonian{TD,VD}
6463
f::F
6564
end
6665

src/Data/multiplier.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ Multiplier: autonomous, fixed (no variable)
5555
See also: [`CTBase.Data.AbstractMultiplier`](@ref), [`CTBase.Data.Hamiltonian`](@ref),
5656
[`CTBase.Traits.TimeDependence`](@ref), [`CTBase.Traits.VariableDependence`](@ref).
5757
"""
58-
struct Multiplier{
59-
F<:Function,TD<:Traits.TimeDependence,VD<:Traits.VariableDependence
60-
} <: AbstractMultiplier{TD,VD}
58+
struct Multiplier{F<:Function,TD<:Traits.TimeDependence,VD<:Traits.VariableDependence} <:
59+
AbstractMultiplier{TD,VD}
6160
f::F
6261
end
6362

src/Plotting/ir.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ function Base.show(io::IO, s::Series)
300300
fmt = Core.get_format_codes(io)
301301
print(io, fmt.name, "Series", fmt.reset, "(")
302302
print(io, fmt.label, repr(s.label), fmt.reset, ", ")
303-
print(io, fmt.value, length(s.x), fmt.reset, " pts)")
303+
return print(io, fmt.value, length(s.x), fmt.reset, " pts)")
304304
end
305305

306306
"""
@@ -330,7 +330,7 @@ See also: `Base.show`
330330
"""
331331
function Base.show(io::IO, h::HLine)
332332
fmt = Core.get_format_codes(io)
333-
print(io, fmt.name, "HLine", fmt.reset, "(", fmt.value, h.value, fmt.reset, ")")
333+
return print(io, fmt.name, "HLine", fmt.reset, "(", fmt.value, h.value, fmt.reset, ")")
334334
end
335335

336336
"""
@@ -357,7 +357,7 @@ See also: `Base.show`
357357
"""
358358
function Base.show(io::IO, v::VLine)
359359
fmt = Core.get_format_codes(io)
360-
print(io, fmt.name, "VLine", fmt.reset, "(", fmt.value, v.value, fmt.reset, ")")
360+
return print(io, fmt.name, "VLine", fmt.reset, "(", fmt.value, v.value, fmt.reset, ")")
361361
end
362362

363363
"""
@@ -386,7 +386,7 @@ function Base.show(io::IO, ax::Axes)
386386
fmt = Core.get_format_codes(io)
387387
print(io, fmt.name, "Axes", fmt.reset, "(")
388388
print(io, fmt.label, repr(ax.title), fmt.reset, ", ")
389-
print(io, fmt.value, length(ax.series), fmt.reset, " series)")
389+
return print(io, fmt.value, length(ax.series), fmt.reset, " series)")
390390
end
391391

392392
"""
@@ -398,7 +398,7 @@ showing its series and decorations.
398398
See also: `Base.show`
399399
"""
400400
function Base.show(io::IO, ::MIME"text/plain", ax::Axes)
401-
_show_axes(io, ax, "")
401+
return _show_axes(io, ax, "")
402402
end
403403

404404
"""
@@ -467,7 +467,7 @@ function Base.show(io::IO, leaf::Leaf)
467467
fmt = Core.get_format_codes(io)
468468
print(io, fmt.name, "Leaf", fmt.reset, "(")
469469
show(io, leaf.axes)
470-
print(io, ")")
470+
return print(io, ")")
471471
end
472472

473473
"""
@@ -478,7 +478,7 @@ Pretty tree-style display of a [`Leaf`](@ref).
478478
See also: `Base.show`
479479
"""
480480
function Base.show(io::IO, ::MIME"text/plain", leaf::Leaf)
481-
_show_node(io, leaf, "")
481+
return _show_node(io, leaf, "")
482482
end
483483

484484
"""
@@ -491,7 +491,7 @@ See also: `Base.show`
491491
function Base.show(io::IO, box::HBox)
492492
fmt = Core.get_format_codes(io)
493493
print(io, fmt.name, "HBox", fmt.reset, "(")
494-
print(io, fmt.value, length(box.children), fmt.reset, " children)")
494+
return print(io, fmt.value, length(box.children), fmt.reset, " children)")
495495
end
496496

497497
"""
@@ -503,7 +503,7 @@ showing its children.
503503
See also: `Base.show`
504504
"""
505505
function Base.show(io::IO, ::MIME"text/plain", box::HBox)
506-
_show_node(io, box, "")
506+
return _show_node(io, box, "")
507507
end
508508

509509
"""
@@ -516,7 +516,7 @@ See also: `Base.show`
516516
function Base.show(io::IO, box::VBox)
517517
fmt = Core.get_format_codes(io)
518518
print(io, fmt.name, "VBox", fmt.reset, "(")
519-
print(io, fmt.value, length(box.children), fmt.reset, " children)")
519+
return print(io, fmt.value, length(box.children), fmt.reset, " children)")
520520
end
521521

522522
"""
@@ -528,7 +528,7 @@ showing its children.
528528
See also: `Base.show`
529529
"""
530530
function Base.show(io::IO, ::MIME"text/plain", box::VBox)
531-
_show_node(io, box, "")
531+
return _show_node(io, box, "")
532532
end
533533

534534
"""
@@ -541,7 +541,7 @@ function _show_node(io::IO, leaf::Leaf, prefix::String)
541541
fmt = Core.get_format_codes(io)
542542
print(io, fmt.name, "Leaf", fmt.reset)
543543
print(io, "\n", prefix, "└─ ")
544-
_show_axes(io, leaf.axes, prefix * " ")
544+
return _show_axes(io, leaf.axes, prefix * " ")
545545
end
546546

547547
function _show_node(io::IO, node::Union{HBox,VBox}, prefix::String)
@@ -578,7 +578,7 @@ function Base.show(io::IO, fig::Figure)
578578
print(io, fmt.label, repr(fig.title), fmt.reset, ", ")
579579
end
580580
show(io, fig.root)
581-
print(io, ")")
581+
return print(io, ")")
582582
end
583583

584584
"""
@@ -599,5 +599,5 @@ function Base.show(io::IO, ::MIME"text/plain", fig::Figure)
599599
print(io, " size: ", fmt.value, fig.size, fmt.reset)
600600
end
601601
print(io, "\n└─ ")
602-
_show_node(io, fig.root, " ")
602+
return _show_node(io, fig.root, " ")
603603
end

src/Plotting/panel.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function Base.show(io::IO, p::Panel)
136136
print(io, fmt.name, "Panel", fmt.reset, "(")
137137
print(io, fmt.label, repr(p.title), fmt.reset, ", ")
138138
print(io, fmt.value, n_components(p), fmt.reset, " components, ")
139-
print(io, fmt.value, length(p.x), fmt.reset, " pts)")
139+
return print(io, fmt.value, length(p.x), fmt.reset, " pts)")
140140
end
141141

142142
"""

test/suite/meta/test_code_quality.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ struct _SkipBenignLoweredCodeUtilsWarnings <: Logging.AbstractLogger
2828
logger::Logging.AbstractLogger
2929
end
3030

31-
Logging.min_enabled_level(l::_SkipBenignLoweredCodeUtilsWarnings) =
32-
Logging.min_enabled_level(l.logger)
31+
function Logging.min_enabled_level(l::_SkipBenignLoweredCodeUtilsWarnings)
32+
return Logging.min_enabled_level(l.logger)
33+
end
3334

34-
Logging.shouldlog(l::_SkipBenignLoweredCodeUtilsWarnings, level, _module, group, id) =
35-
Logging.shouldlog(l.logger, level, _module, group, id)
35+
function Logging.shouldlog(
36+
l::_SkipBenignLoweredCodeUtilsWarnings, level, _module, group, id
37+
)
38+
return Logging.shouldlog(l.logger, level, _module, group, id)
39+
end
3640

3741
function Logging.handle_message(
3842
l::_SkipBenignLoweredCodeUtilsWarnings,

test/suite/meta/test_data_subtyping.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const VERBOSE = isdefined(Main, :TestData) ? Main.TestData.VERBOSE : true
2525
const SHOWTIMING = isdefined(Main, :TestData) ? Main.TestData.SHOWTIMING : true
2626

2727
function test_data_subtyping()
28-
Test.@testset "Struct <: AbstractParent (bound-dropping regression guard)" verbose = VERBOSE showtiming =
29-
SHOWTIMING begin
28+
Test.@testset "Struct <: AbstractParent (bound-dropping regression guard)" verbose =
29+
VERBOSE showtiming = SHOWTIMING begin
3030
Test.@testset "Fixed in this pass" begin
3131
Test.@test Data.Hamiltonian <: Data.AbstractHamiltonian
3232
Test.@test Data.PseudoHamiltonian <: Data.AbstractPseudoHamiltonian

test/suite/meta/test_performance.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ function test_performance()
8383
# 2. Zero-allocation reads: interpolant eval, trait reads, option reads
8484
# ======================================================================
8585
Test.@testset "Zero-allocation reads" begin
86-
interp_l = Interpolation.ctinterpolate([0.0, 1.0, 2.0, 3.0], [1.0, 2.0, 1.5, 3.0])
86+
interp_l = Interpolation.ctinterpolate(
87+
[0.0, 1.0, 2.0, 3.0], [1.0, 2.0, 1.5, 3.0]
88+
)
8789
Test.@test (BenchmarkTools.@ballocated $interp_l(1.5)) == 0
8890

8991
interp_c = Interpolation.ctinterpolate_constant(
@@ -101,7 +103,8 @@ function test_performance()
101103
Test.@test (BenchmarkTools.@ballocated Traits.feedback($cl)) == 0
102104

103105
backend = Differentiation.DifferentiationInterface()
104-
Test.@test (BenchmarkTools.@ballocated Differentiation.ad_backend($backend)) == 0
106+
Test.@test (BenchmarkTools.@ballocated Differentiation.ad_backend($backend)) ==
107+
0
105108
end
106109
end
107110
return nothing

test/suite/plotting/test_display.jl

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ _sprint_show(x) = sprint(show, x)
1111
_sprint_plain(x) = sprint(show, MIME"text/plain"(), x)
1212

1313
# Helper builders
14-
_series(label="x(t)", n=3) = Plotting.Series(
15-
collect(Float64, 1:n), collect(Float64, 1:n); label=label,
16-
)
17-
_axes(; title="State", xlabel="t", ylabel="x", nseries=1) = Plotting.Axes(
18-
[_series("s$i") for i in 1:nseries]; title=title,
19-
xlabel=xlabel, ylabel=ylabel,
20-
)
14+
function _series(label="x(t)", n=3)
15+
return Plotting.Series(collect(Float64, 1:n), collect(Float64, 1:n); label=label)
16+
end
17+
function _axes(; title="State", xlabel="t", ylabel="x", nseries=1)
18+
return Plotting.Axes(
19+
[_series("s$i") for i in 1:nseries]; title=title, xlabel=xlabel, ylabel=ylabel
20+
)
21+
end
2122
_leaf(; title="State") = Plotting.Leaf(_axes(; title=title))
2223

2324
function test_display()
@@ -91,9 +92,7 @@ function test_display()
9192
end
9293

9394
Test.@testset "Figure compact" begin
94-
fig = Plotting.Figure(
95-
Plotting.VBox([_leaf()]); title="Solution",
96-
)
95+
fig = Plotting.Figure(Plotting.VBox([_leaf()]); title="Solution")
9796
out = _sprint_show(fig)
9897
Test.@test occursin("Figure", out)
9998
Test.@test occursin("Solution", out)
@@ -128,8 +127,10 @@ function test_display()
128127
Test.@testset "Unit — pretty" begin
129128
Test.@testset "Series pretty" begin
130129
s = Plotting.Series(
131-
[0.0, 1.0, 2.0], [0.0, 1.0, 0.0];
132-
label="x(t)", style=(color=:blue, linewidth=2),
130+
[0.0, 1.0, 2.0],
131+
[0.0, 1.0, 0.0];
132+
label="x(t)",
133+
style=(color=:blue, linewidth=2),
133134
)
134135
out = _sprint_plain(s)
135136
Test.@test occursin("Series", out)
@@ -166,7 +167,9 @@ function test_display()
166167
Test.@testset "Axes pretty — series and labels" begin
167168
ax = Plotting.Axes(
168169
[_series("x(t)", 3), _series("y(t)", 2)];
169-
title="State", xlabel="t", ylabel="x",
170+
title="State",
171+
xlabel="t",
172+
ylabel="x",
170173
)
171174
out = _sprint_plain(ax)
172175
Test.@test occursin("Axes", out)
@@ -223,9 +226,7 @@ function test_display()
223226
Test.@testset "Figure pretty — full tree" begin
224227
leaf1 = _leaf(; title="State")
225228
leaf2 = _leaf(; title="Control")
226-
fig = Plotting.Figure(
227-
Plotting.VBox([leaf1, leaf2]); title="Solution",
228-
)
229+
fig = Plotting.Figure(Plotting.VBox([leaf1, leaf2]); title="Solution")
229230
out = _sprint_plain(fig)
230231
Test.@test occursin("Figure", out)
231232
Test.@test occursin("Solution", out)
@@ -235,9 +236,7 @@ function test_display()
235236
end
236237

237238
Test.@testset "Figure pretty — size shown" begin
238-
fig = Plotting.Figure(
239-
_leaf(); title="Fig", size=(800, 600),
240-
)
239+
fig = Plotting.Figure(_leaf(); title="Fig", size=(800, 600))
241240
out = _sprint_plain(fig)
242241
Test.@test occursin("size", out)
243242
Test.@test occursin("800", out)
@@ -270,9 +269,7 @@ function test_display()
270269
Test.@testset "Panel pretty — partial labels" begin
271270
t = collect(0.0:0.1:1.0)
272271
data = hcat(sin.(t), cos.(t), t)
273-
panel = Plotting.Panel(
274-
t, data; title="Mix", labels=["a", "", "c"],
275-
)
272+
panel = Plotting.Panel(t, data; title="Mix", labels=["a", "", "c"])
276273
out = _sprint_plain(panel)
277274
Test.@test occursin("a", out)
278275
Test.@test occursin("c", out)
@@ -281,10 +278,7 @@ function test_display()
281278
end
282279

283280
Test.@testset "Panel pretty — singular" begin
284-
panel = Plotting.Panel(
285-
[0.0], reshape([1.0], :, 1);
286-
title="S", labels=["u"],
287-
)
281+
panel = Plotting.Panel([0.0], reshape([1.0], :, 1); title="S", labels=["u"])
288282
out = _sprint_plain(panel)
289283
Test.@test occursin("1 component", out)
290284
Test.@test occursin("1 point", out)
@@ -310,9 +304,7 @@ function test_display()
310304
end
311305

312306
Test.@testset "Truncation beyond limit" begin
313-
leaves = [
314-
_leaf(; title="C$i") for i in 1:8
315-
]
307+
leaves = [_leaf(; title="C$i") for i in 1:8]
316308
box = Plotting.VBox(leaves)
317309
out = _sprint_plain(box)
318310
Test.@test occursin("8", out)
@@ -326,10 +318,7 @@ function test_display()
326318
leaf1 = _leaf(; title="State")
327319
leaf2 = _leaf(; title="Costate")
328320
leaf3 = _leaf(; title="Control")
329-
tree = Plotting.VBox([
330-
Plotting.HBox([leaf1, leaf2]),
331-
leaf3,
332-
])
321+
tree = Plotting.VBox([Plotting.HBox([leaf1, leaf2]), leaf3])
333322
fig = Plotting.Figure(tree; title="Solution")
334323
out = _sprint_plain(fig)
335324
Test.@test occursin("Figure", out)

test/suite/strategies/test_describe_registry.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ struct FakeGenericStrat{P<:Strategies.AbstractStrategyParameter} end
1111
struct FakeConcreteStrat end
1212

1313
function test_describe_registry()
14-
Test.@testset "Describe registry - private helpers" verbose = VERBOSE showtiming = SHOWTIMING begin
14+
Test.@testset "Describe registry - private helpers" verbose = VERBOSE showtiming =
15+
SHOWTIMING begin
1516

1617
# ====================================================================
1718
# UNIT TESTS - _strategy_type_name

0 commit comments

Comments
 (0)