Skip to content

Commit c6b4754

Browse files
committed
Add more testsets
1 parent fb895fa commit c6b4754

File tree

1 file changed

+37
-32
lines changed

1 file changed

+37
-32
lines changed

test/sparse.jl

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,33 @@ end
5050
end
5151

5252
@testset "KnownJacobianSparsityDetector" begin
53-
@testset "Out-of-place functions" begin
54-
for sx in ((2,), (2, 3)), f in (f_jac1, f_jac2)
55-
x = rand(sx...)
56-
nx = length(x)
57-
Jref = rand(Bool, 2 * nx, nx)
58-
sd = KnownJacobianSparsityDetector(Jref)
59-
Js = jacobian_sparsity(f, x, sd)
60-
@test Js isa AbstractMatrix
61-
@test size(Js) == (2 * nx, nx)
62-
@test Js === Jref
53+
@testset "Jacobian sparsity detection" begin
54+
@testset "Out-of-place functions" begin
55+
for sx in ((2,), (2, 3)), f in (f_jac1, f_jac2)
56+
x = rand(sx...)
57+
nx = length(x)
58+
Jref = rand(Bool, 2 * nx, nx)
59+
sd = KnownJacobianSparsityDetector(Jref)
60+
Js = jacobian_sparsity(f, x, sd)
61+
@test Js isa AbstractMatrix
62+
@test size(Js) == (2 * nx, nx)
63+
@test Js === Jref
64+
end
6365
end
64-
end
65-
@testset "In-place functions" begin
66-
for sx in ((2,), (2, 3)), sy in ((5,), (5, 6))
67-
x, y = rand(sx...), rand(sy...)
68-
nx, ny = length(x), length(y)
69-
Jref = rand(Bool, ny, nx)
70-
sd = KnownJacobianSparsityDetector(Jref)
71-
Js = jacobian_sparsity(f_jac!, y, x, sd)
72-
@test Js isa AbstractMatrix
73-
@test size(Js) == (ny, nx)
74-
@test Js === Jref
66+
@testset "In-place functions" begin
67+
for sx in ((2,), (2, 3)), sy in ((5,), (5, 6))
68+
x, y = rand(sx...), rand(sy...)
69+
nx, ny = length(x), length(y)
70+
Jref = rand(Bool, ny, nx)
71+
sd = KnownJacobianSparsityDetector(Jref)
72+
Js = jacobian_sparsity(f_jac!, y, x, sd)
73+
@test Js isa AbstractMatrix
74+
@test size(Js) == (ny, nx)
75+
@test Js === Jref
76+
end
7577
end
7678
end
77-
@testset "Exceptions: hessian_sparsity not supported" begin
79+
@testset "Exceptions: Hessian sparsity detection not supported" begin
7880
for sx in ((2,), (2, 3))
7981
x = rand(sx...)
8082
nx = length(x)
@@ -93,19 +95,22 @@ end
9395
end
9496
end
9597
end
98+
9699
@testset "KnownHessianSparsityDetector" begin
97-
for sx in ((2,), (2, 3))
98-
x = rand(sx...)
99-
nx = length(x)
100-
Href = rand(Bool, nx, nx)
101-
sd = KnownHessianSparsityDetector(Href)
100+
@testset "Hessian sparsity detection" begin
101+
for sx in ((2,), (2, 3))
102+
x = rand(sx...)
103+
nx = length(x)
104+
Href = rand(Bool, nx, nx)
105+
sd = KnownHessianSparsityDetector(Href)
102106

103-
Hs = hessian_sparsity(f_hess, x, sd)
104-
@test Hs isa AbstractMatrix
105-
@test size(Hs) == (nx, nx)
106-
@test Hs === Href
107+
Hs = hessian_sparsity(f_hess, x, sd)
108+
@test Hs isa AbstractMatrix
109+
@test size(Hs) == (nx, nx)
110+
@test Hs === Href
111+
end
107112
end
108-
@testset "Exceptions: jacobian_sparsity not supported" begin
113+
@testset "Exceptions: Jacobian sparsity detection not supported" begin
109114
@testset "Out-of-place functions" begin
110115
for sx in ((2,), (2, 3)), f in (f_jac1, f_jac2)
111116
x = rand(sx...)

0 commit comments

Comments
 (0)