Skip to content

Commit 437f517

Browse files
committed
begin fix tests
1 parent b5a04be commit 437f517

File tree

2 files changed

+33
-34
lines changed

2 files changed

+33
-34
lines changed

test/manual.jl

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,13 @@ function test_nlp_consistency(nlp, model; counters = true)
44
v = 2 * ones(nvar)
55
y = ones(ncon)
66

7-
@test grad(nlp, x) == grad(model, x)
8-
@test !counters || (neval_grad(model) == 2)
9-
@test hess_coord(nlp, x) == hess_coord(model, x)
10-
@test !counters || (neval_hess(model) == 2)
11-
@test hprod(nlp, x, v) == hprod(model, x, v)
12-
@test !counters || (neval_hprod(model) == 2)
7+
# TODO: only test the backends that are defined
138
if model.meta.nnln > 0
149
@test jac(nlp, x) == jac(model, x)
1510
@test !counters || (neval_jac_nln(model) == 2)
1611
@test jprod(nlp, x, v) == jprod(model, x, v)
1712
@test !counters || (neval_jprod_nln(model) == 2)
1813
@test jtprod(nlp, x, y) == jtprod(model, x, y)
19-
@test hess_coord(nlp, x, y) == hess_coord(model, x, y)
20-
@test !counters || (neval_hess(model) == 4)
21-
@test hprod(nlp, x, y, v) == hprod(model, x, y, v)
22-
@test !counters || (neval_hprod(model) == 4)
23-
@test ghjvprod(nlp, x, x, v) == ghjvprod(model, x, x, v)
24-
@test !counters || (neval_hprod(model) == 6)
25-
for j in model.meta.nln
26-
@test jth_hess(nlp, x, j) == jth_hess(model, x, j)
27-
@test jth_hprod(nlp, x, v, j) == jth_hprod(model, x, v, j)
28-
end
2914
end
3015

3116
if (nlp isa AbstractNLSModel) && (model isa AbstractNLSModel)
@@ -41,6 +26,25 @@ function test_nlp_consistency(nlp, model; counters = true)
4126
#for i=1:nequ
4227
# @test hprod_residual(nlp, x, i, v) == hprod_residual(model, x, i, v)
4328
#end
29+
else
30+
@test grad(nlp, x) == grad(model, x)
31+
@test !counters || (neval_grad(model) == 2)
32+
@test hess_coord(nlp, x) == hess_coord(model, x)
33+
@test !counters || (neval_hess(model) == 2)
34+
@test hprod(nlp, x, v) == hprod(model, x, v)
35+
@test !counters || (neval_hprod(model) == 2)
36+
if model.meta.nnln > 0
37+
@test hess_coord(nlp, x, y) == hess_coord(model, x, y)
38+
@test !counters || (neval_hess(model) == 4)
39+
@test hprod(nlp, x, y, v) == hprod(model, x, y, v)
40+
@test !counters || (neval_hprod(model) == 4)
41+
@test ghjvprod(nlp, x, x, v) == ghjvprod(model, x, x, v)
42+
@test !counters || (neval_hprod(model) == 6)
43+
for j in model.meta.nln
44+
@test jth_hess(nlp, x, j) == jth_hess(model, x, j)
45+
@test jth_hprod(nlp, x, v, j) == jth_hprod(model, x, v, j)
46+
end
47+
end
4448
end
4549
end
4650

@@ -250,18 +254,12 @@ end
250254
c!,
251255
lcon,
252256
ucon,
253-
gradient_backend = adbackend.gradient_backend,
254-
hprod_backend = adbackend.hprod_backend,
255-
hessian_backend = adbackend.hessian_backend,
256257
jprod_backend = adbackend.jprod_backend,
257258
jtprod_backend = adbackend.jtprod_backend,
258259
jacobian_backend = adbackend.jacobian_backend,
259-
ghjvprod_backend = adbackend.ghjvprod_backend,
260-
hprod_residual_backend = adbackend.hprod_residual_backend,
261260
jprod_residual_backend = adbackend.jprod_residual_backend,
262261
jtprod_residual_backend = adbackend.jtprod_residual_backend,
263262
jacobian_residual_backend = adbackend.jacobian_residual_backend,
264-
hessian_residual_backend = adbackend.hessian_residual_backend,
265263
)
266264
test_nlp_consistency(nlp, nlp; counters = false)
267265
end

test/nls/nlpmodelstest.jl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,32 @@ function nls_nlpmodelstest(backend)
1313
push!(nlss, eval(Meta.parse(spc))())
1414
end
1515

16-
exclude = if problem == "LLS"
17-
[hess_coord, hess]
18-
elseif problem == "MGH01"
19-
[hess_coord, hess, ghjvprod]
20-
else
21-
[]
22-
end
16+
# TODO: test backends that are defined
17+
# exclude = if problem == "LLS"
18+
# [hess_coord, hess]
19+
# elseif problem == "MGH01"
20+
# [hess_coord, hess, ghjvprod]
21+
# else
22+
# []
23+
# end
2324

2425
for nls in nlss
2526
show(IOBuffer(), nls)
2627
end
2728

2829
@testset "Check Consistency" begin
29-
consistent_nlss([nlss; nls_man], exclude = exclude, linear_api = true)
30+
consistent_nlss([nlss; nls_man], linear_api = true)
3031
end
3132
@testset "Check dimensions" begin
32-
check_nls_dimensions.(nlss, exclude = exclude)
33-
check_nlp_dimensions.(nlss, exclude = exclude, linear_api = true)
33+
check_nls_dimensions.(nlss)
34+
check_nlp_dimensions.(nlss, linear_api = true)
3435
end
3536
@testset "Check multiple precision" begin
36-
multiple_precision_nls(nls_from_T, exclude = exclude, linear_api = true)
37+
multiple_precision_nls(nls_from_T, linear_api = true)
3738
end
3839
if backend != :enzyme
3940
@testset "Check view subarray" begin
40-
view_subarray_nls.(nlss, exclude = exclude)
41+
view_subarray_nls.(nlss)
4142
end
4243
end
4344
end

0 commit comments

Comments
 (0)