Skip to content

Commit 4e96c87

Browse files
authored
remove test on counters if redefined (#58)
1 parent a0a57bc commit 4e96c87

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/nlp/consistency.jl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,21 @@ function consistent_nlps(
1616
nlps;
1717
exclude = [jth_hess, jth_hess_coord, jth_hprod, ghjvprod],
1818
linear_api = false,
19+
reimplemented = [],
1920
test_meta = true,
2021
test_slack = true,
2122
test_qn = true,
2223
test_derivative = true,
2324
rtol = 1.0e-8,
2425
)
25-
consistent_counters(nlps, linear_api = linear_api)
26+
consistent_counters(nlps, linear_api = linear_api, reimplemented = reimplemented)
2627
test_meta && consistent_meta(nlps, rtol = rtol)
2728
consistent_functions(nlps, linear_api = linear_api, rtol = rtol, exclude = exclude)
28-
consistent_counters(nlps, linear_api = linear_api)
29+
consistent_counters(nlps, linear_api = linear_api, reimplemented = reimplemented)
2930
for nlp in nlps
3031
reset!(nlp)
3132
end
32-
consistent_counters(nlps, linear_api = linear_api)
33+
consistent_counters(nlps, linear_api = linear_api, reimplemented = reimplemented)
3334
if test_derivative
3435
for nlp in nlps
3536
@test length(gradient_check(nlp)) == 0
@@ -50,7 +51,7 @@ function consistent_nlps(
5051
linear_api = linear_api,
5152
exclude = [hess, hess_coord, hprod, jth_hess, jth_hess_coord, jth_hprod, ghjvprod] exclude,
5253
)
53-
consistent_counters([nlps; qnmodels], linear_api = linear_api)
54+
consistent_counters([nlps; qnmodels], linear_api = linear_api, reimplemented = reimplemented)
5455
end
5556

5657
if test_slack && has_inequalities(nlps[1])
@@ -61,7 +62,7 @@ function consistent_nlps(
6162
linear_api = linear_api,
6263
exclude = [jth_hess, jth_hess_coord, jth_hprod] exclude,
6364
)
64-
consistent_counters(slack_nlps, linear_api = linear_api)
65+
consistent_counters(slack_nlps, linear_api = linear_api, reimplemented = reimplemented)
6566
end
6667
end
6768

@@ -79,7 +80,7 @@ function consistent_meta(nlps; rtol = 1.0e-8)
7980
end
8081
end
8182

82-
function consistent_counters(nlps; linear_api = false)
83+
function consistent_counters(nlps; linear_api = false, reimplemented = String[])
8384
N = length(nlps)
8485
V = zeros(Int, N)
8586
check_fields = filter(
@@ -96,8 +97,11 @@ function consistent_counters(nlps; linear_api = false)
9697
end
9798
if linear_api
9899
V = [sum_counters(nlp) for nlp in nlps]
99-
@test all(V .== V[1])
100+
@test (reimplemented != []) | all(V .== V[1])
100101
for field in setdiff(collect(fieldnames(Counters)), check_fields)
102+
if any(x -> occursin(x, string(field)), reimplemented)
103+
continue
104+
end
101105
V = [eval(field)(nlp) for nlp in nlps]
102106
@testset "Field $field" begin
103107
for i = 1:(N - 1)

0 commit comments

Comments
 (0)