Skip to content

Commit

Permalink
remove test on counters if redefined (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmigot authored Aug 21, 2022
1 parent a0a57bc commit 4e96c87
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/nlp/consistency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ function consistent_nlps(
nlps;
exclude = [jth_hess, jth_hess_coord, jth_hprod, ghjvprod],
linear_api = false,
reimplemented = [],
test_meta = true,
test_slack = true,
test_qn = true,
test_derivative = true,
rtol = 1.0e-8,
)
consistent_counters(nlps, linear_api = linear_api)
consistent_counters(nlps, linear_api = linear_api, reimplemented = reimplemented)
test_meta && consistent_meta(nlps, rtol = rtol)
consistent_functions(nlps, linear_api = linear_api, rtol = rtol, exclude = exclude)
consistent_counters(nlps, linear_api = linear_api)
consistent_counters(nlps, linear_api = linear_api, reimplemented = reimplemented)
for nlp in nlps
reset!(nlp)
end
consistent_counters(nlps, linear_api = linear_api)
consistent_counters(nlps, linear_api = linear_api, reimplemented = reimplemented)
if test_derivative
for nlp in nlps
@test length(gradient_check(nlp)) == 0
Expand All @@ -50,7 +51,7 @@ function consistent_nlps(
linear_api = linear_api,
exclude = [hess, hess_coord, hprod, jth_hess, jth_hess_coord, jth_hprod, ghjvprod] exclude,
)
consistent_counters([nlps; qnmodels], linear_api = linear_api)
consistent_counters([nlps; qnmodels], linear_api = linear_api, reimplemented = reimplemented)
end

if test_slack && has_inequalities(nlps[1])
Expand All @@ -61,7 +62,7 @@ function consistent_nlps(
linear_api = linear_api,
exclude = [jth_hess, jth_hess_coord, jth_hprod] exclude,
)
consistent_counters(slack_nlps, linear_api = linear_api)
consistent_counters(slack_nlps, linear_api = linear_api, reimplemented = reimplemented)
end
end

Expand All @@ -79,7 +80,7 @@ function consistent_meta(nlps; rtol = 1.0e-8)
end
end

function consistent_counters(nlps; linear_api = false)
function consistent_counters(nlps; linear_api = false, reimplemented = String[])
N = length(nlps)
V = zeros(Int, N)
check_fields = filter(
Expand All @@ -96,8 +97,11 @@ function consistent_counters(nlps; linear_api = false)
end
if linear_api
V = [sum_counters(nlp) for nlp in nlps]
@test all(V .== V[1])
@test (reimplemented != []) | all(V .== V[1])
for field in setdiff(collect(fieldnames(Counters)), check_fields)
if any(x -> occursin(x, string(field)), reimplemented)
continue
end
V = [eval(field)(nlp) for nlp in nlps]
@testset "Field $field" begin
for i = 1:(N - 1)
Expand Down

0 comments on commit 4e96c87

Please sign in to comment.