|
50 | 50 | end
|
51 | 51 |
|
52 | 52 | @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 |
63 | 65 | 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 |
75 | 77 | end
|
76 | 78 | end
|
77 |
| - @testset "Exceptions: hessian_sparsity not supported" begin |
| 79 | + @testset "Exceptions: Hessian sparsity detection not supported" begin |
78 | 80 | for sx in ((2,), (2, 3))
|
79 | 81 | x = rand(sx...)
|
80 | 82 | nx = length(x)
|
|
93 | 95 | end
|
94 | 96 | end
|
95 | 97 | end
|
| 98 | + |
96 | 99 | @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) |
102 | 106 |
|
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 |
107 | 112 | end
|
108 |
| - @testset "Exceptions: jacobian_sparsity not supported" begin |
| 113 | + @testset "Exceptions: Jacobian sparsity detection not supported" begin |
109 | 114 | @testset "Out-of-place functions" begin
|
110 | 115 | for sx in ((2,), (2, 3)), f in (f_jac1, f_jac2)
|
111 | 116 | x = rand(sx...)
|
|
0 commit comments