Skip to content

Commit 602b784

Browse files
authored
Merge pull request #448 from control-toolbox/auto-juliaformatter-pr
[AUTO] JuliaFormatter.jl run
2 parents 379b945 + 3acfeb2 commit 602b784

5 files changed

Lines changed: 51 additions & 30 deletions

File tree

src/Interpolation/display.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Interpolant (linear): 3 nodes
1111
"""
1212
function Base.show(io::IO, interp::Interpolant{M}) where {M}
1313
label = M === Linear ? "linear" : "piecewise-constant"
14-
print(io, "Interpolant ($label): $(length(interp.x)) nodes")
14+
return print(io, "Interpolant ($label): $(length(interp.x)) nodes")
1515
end
1616

1717
"""

test/suite/core/test_function_utils.jl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
module TestCoreFunctionUtils
22

3-
import Test
3+
using Test: Test
44
import CTBase.Core
55

66
const VERBOSE = isdefined(Main, :TestOptions) ? Main.TestOptions.VERBOSE : true
77
const SHOWTIMING = isdefined(Main, :TestOptions) ? Main.TestOptions.SHOWTIMING : true
88

99
function test_function_utils()
1010
Test.@testset verbose = VERBOSE showtiming = SHOWTIMING "to_out_of_place" begin
11-
1211
Test.@testset "to_out_of_place - basic conversion" begin
13-
f!(r, x) = (r[1] = sin(x); r[2] = cos(x))
12+
f!(r, x) = (r[1]=sin(x); r[2]=cos(x))
1413
f = Core.to_out_of_place(f!, 2)
1514
result = f/ 4)
1615
Test.@test result isa Vector
@@ -28,7 +27,7 @@ function test_function_utils()
2827
end
2928

3029
Test.@testset "to_out_of_place - with kwargs" begin
31-
h!(r, x; scale=1.0) = (r[1] = x * scale; r[2] = x^2 * scale)
30+
h!(r, x; scale=1.0) = (r[1]=x * scale; r[2]=x^2 * scale)
3231
h = Core.to_out_of_place(h!, 2)
3332
Test.@test h(2.0)[1] 2.0
3433
Test.@test h(2.0)[2] 4.0
@@ -37,15 +36,15 @@ function test_function_utils()
3736
end
3837

3938
Test.@testset "to_out_of_place - multiple arguments" begin
40-
k!(r, x, y) = (r[1] = x + y; r[2] = x * y)
39+
k!(r, x, y) = (r[1]=x + y; r[2]=x * y)
4140
k = Core.to_out_of_place(k!, 2)
4241
result = k(3.0, 4.0)
4342
Test.@test result[1] 7.0
4443
Test.@test result[2] 12.0
4544
end
4645

4746
Test.@testset "to_out_of_place - custom type" begin
48-
m!(r, x) = (r[1] = x + 1; r[2] = x + 2)
47+
m!(r, x) = (r[1]=x + 1; r[2]=x + 2)
4948
m = Core.to_out_of_place(m!, 2; T=Int)
5049
result = m(5)
5150
Test.@test result isa Vector{Int}
@@ -58,13 +57,17 @@ function test_function_utils()
5857
end
5958

6059
Test.@testset "to_out_of_place - larger output" begin
61-
big!(r, x) = (for i in 1:5; r[i] = x * i; end)
60+
big!(r, x) = (
61+
for i in 1:5
62+
;
63+
r[i] = x * i;
64+
end
65+
)
6266
big = Core.to_out_of_place(big!, 5)
6367
result = big(2.0)
6468
Test.@test length(result) == 5
6569
Test.@test result == [2.0, 4.0, 6.0, 8.0, 10.0]
6670
end
67-
6871
end
6972
return nothing
7073
end

test/suite/core/test_macros.jl

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

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

@@ -9,33 +9,52 @@ const SHOWTIMING = isdefined(Main, :TestOptions) ? Main.TestOptions.SHOWTIMING :
99

1010
function test_macros()
1111
Test.@testset verbose = VERBOSE showtiming = SHOWTIMING "@ensure" begin
12-
1312
Test.@testset "@ensure - condition true" begin
1413
x = 5
15-
Test.@test_nowarn Core.@ensure x > 0 Exceptions.IncorrectArgument("x must be positive")
16-
Test.@test_nowarn Core.@ensure x == 5 Exceptions.IncorrectArgument("x must be 5")
14+
Test.@test_nowarn Core.@ensure x > 0 Exceptions.IncorrectArgument(
15+
"x must be positive"
16+
)
17+
Test.@test_nowarn Core.@ensure x == 5 Exceptions.IncorrectArgument(
18+
"x must be 5"
19+
)
1720
end
1821

1922
Test.@testset "@ensure - condition false" begin
2023
x = -5
21-
Test.@test_throws Exceptions.IncorrectArgument Core.@ensure x > 0 Exceptions.IncorrectArgument("x must be positive")
24+
Test.@test_throws Exceptions.IncorrectArgument Core.@ensure x > 0 Exceptions.IncorrectArgument(
25+
"x must be positive"
26+
)
2227
y = 10
23-
Test.@test_throws Exceptions.IncorrectArgument Core.@ensure y < 0 Exceptions.IncorrectArgument("y must be negative")
28+
Test.@test_throws Exceptions.IncorrectArgument Core.@ensure y < 0 Exceptions.IncorrectArgument(
29+
"y must be negative"
30+
)
2431
end
2532

2633
Test.@testset "@ensure - with different exception types" begin
2734
x = 0
28-
Test.@test_throws ArgumentError Core.@ensure x != 0 ArgumentError("x cannot be zero")
29-
Test.@test_throws DomainError Core.@ensure x > 0 DomainError(x, "x must be positive")
35+
Test.@test_throws ArgumentError Core.@ensure x != 0 ArgumentError(
36+
"x cannot be zero"
37+
)
38+
Test.@test_throws DomainError Core.@ensure x > 0 DomainError(
39+
x, "x must be positive"
40+
)
3041
end
3142

3243
Test.@testset "@ensure - complex conditions" begin
3344
x = 5
3445
y = 10
35-
Test.@test_nowarn Core.@ensure x < y Exceptions.IncorrectArgument("x must be less than y")
36-
Test.@test_throws Exceptions.IncorrectArgument Core.@ensure x > y Exceptions.IncorrectArgument("x must be greater than y")
37-
Test.@test_nowarn Core.@ensure (x > 0 && y > 0) Exceptions.IncorrectArgument("both must be positive")
38-
Test.@test_throws Exceptions.IncorrectArgument Core.@ensure (x < 0 || y < 0) Exceptions.IncorrectArgument("at least one must be negative")
46+
Test.@test_nowarn Core.@ensure x < y Exceptions.IncorrectArgument(
47+
"x must be less than y"
48+
)
49+
Test.@test_throws Exceptions.IncorrectArgument Core.@ensure x > y Exceptions.IncorrectArgument(
50+
"x must be greater than y"
51+
)
52+
Test.@test_nowarn Core.@ensure (x > 0 && y > 0) Exceptions.IncorrectArgument(
53+
"both must be positive"
54+
)
55+
Test.@test_throws Exceptions.IncorrectArgument Core.@ensure (x < 0 || y < 0) Exceptions.IncorrectArgument(
56+
"at least one must be negative"
57+
)
3958
end
4059

4160
Test.@testset "@ensure - exception message verification" begin
@@ -51,10 +70,13 @@ function test_macros()
5170

5271
Test.@testset "@ensure - with type checks" begin
5372
x = 5
54-
Test.@test_nowarn Core.@ensure x isa Int Exceptions.IncorrectArgument("x must be an Int")
55-
Test.@test_throws Exceptions.IncorrectArgument Core.@ensure x isa String Exceptions.IncorrectArgument("x must be a String")
73+
Test.@test_nowarn Core.@ensure x isa Int Exceptions.IncorrectArgument(
74+
"x must be an Int"
75+
)
76+
Test.@test_throws Exceptions.IncorrectArgument Core.@ensure x isa String Exceptions.IncorrectArgument(
77+
"x must be a String"
78+
)
5679
end
57-
5880
end
5981
return nothing
6082
end

test/suite/core/test_matrix_utils.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
module TestCoreMatrixUtils
22

3-
import Test
3+
using Test: Test
44
import CTBase.Core
55

66
const VERBOSE = isdefined(Main, :TestOptions) ? Main.TestOptions.VERBOSE : true
77
const SHOWTIMING = isdefined(Main, :TestOptions) ? Main.TestOptions.SHOWTIMING : true
88

99
function test_matrix_utils()
1010
Test.@testset verbose = VERBOSE showtiming = SHOWTIMING "matrix2vec" begin
11-
1211
Test.@testset "matrix2vec - dimension 1 (rows)" begin
1312
A = [0 1; 2 3]
1413
V = Core.matrix2vec(A)
@@ -62,7 +61,6 @@ function test_matrix_utils()
6261
Test.@test W[1] [1.5, 3.5]
6362
Test.@test W[2] [2.5, 4.5]
6463
end
65-
6664
end
6765
return nothing
6866
end

test/suite/interpolation/test_interpolation.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
module TestInterpolation
22

3-
import Test
3+
using Test: Test
44
import CTBase.Interpolation
55

66
const VERBOSE = isdefined(Main, :TestOptions) ? Main.TestOptions.VERBOSE : true
77
const SHOWTIMING = isdefined(Main, :TestOptions) ? Main.TestOptions.SHOWTIMING : true
88

99
function test_interpolation()
1010
Test.@testset verbose = VERBOSE showtiming = SHOWTIMING "Interpolation" begin
11-
1211
Test.@testset "ctinterpolate - basic linear interpolation" begin
1312
x = [0.0, 1.0, 2.0]
1413
f = [0.0, 1.0, 0.0]
@@ -132,7 +131,6 @@ function test_interpolation()
132131
Test.@test_nowarn Test.@inferred interp(0.5)
133132
Test.@test_nowarn Test.@inferred c(0.5)
134133
end
135-
136134
end
137135
return nothing
138136
end

0 commit comments

Comments
 (0)