Skip to content

Commit eed316b

Browse files
committed
Improve variable names in inference.jl
1 parent cacf6f0 commit eed316b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

test/inference.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ end
1313

1414
@testset "cached, rescaled contract" begin
1515
model_filepath, evidence_filepath, solution_filepath = get_instance_filepaths("Promedus_14", "MAR")
16-
problem = read_instance(model_filepath; evidence_filepath, solution_filepath)
17-
ref_sol = problem.reference_marginals
16+
instance = read_instance(model_filepath; evidence_filepath, solution_filepath)
17+
ref_sol = instance.reference_marginals
1818
optimizer = TreeSA(ntrials = 1, niters = 5, βs = 0.1:0.1:100)
19-
tn = TensorNetworkModel(problem; optimizer)
19+
tn = TensorNetworkModel(instance; optimizer)
2020
p1 = probability(tn; usecuda = false, rescale = false)
2121
p2 = probability(tn; usecuda = false, rescale = true)
2222
@test p1 Array(p2)
@@ -30,11 +30,11 @@ end
3030

3131
# compute marginals
3232
ti_sol = marginals(tn)
33-
ref_sol[problem.obsvars] .= fill([1.0], length(problem.obsvars)) # imitate dummy vars
33+
ref_sol[instance.obsvars] .= fill([1.0], length(instance.obsvars)) # imitate dummy vars
3434
@test isapprox(ti_sol, ref_sol; atol = 1e-5)
3535
end
3636

37-
function get_problems(problem_set::String)
37+
function get_problems_names(problem_set::String)
3838
# Capture the problem names that belong to the current problem_set
3939
regex = Regex("($(problem_set)_\\d*)(\\.uai)\$")
4040
return readdir(joinpath(artifact"uai2014", "MAR"); sort = false) |>
@@ -61,18 +61,18 @@ end
6161
@testset "$(problem_set) problem_set" begin
6262

6363
# Capture the problem names that belong to the current problem set
64-
problems = get_problems(problem_set)
64+
problem_names = get_problems_names(problem_set)
6565

66-
for problem in problems
67-
@info "Testing: $problem"
68-
@testset "$(problem)" begin
69-
model_filepath, evidence_filepath, solution_filepath = get_instance_filepaths(problem, "MAR")
70-
problem = read_instance(model_filepath; evidence_filepath, solution_filepath)
71-
ref_sol = problem.reference_marginals
72-
obsvars = problem.obsvars
66+
for problem_name in problem_names
67+
@info "Testing: $problem_name"
68+
@testset "$(problem_name)" begin
69+
model_filepath, evidence_filepath, solution_filepath = get_instance_filepaths(problem_name, "MAR")
70+
instance = read_instance(model_filepath; evidence_filepath, solution_filepath)
71+
ref_sol = instance.reference_marginals
72+
obsvars = instance.obsvars
7373

7474
# does not optimize over open vertices
75-
tn = TensorNetworkModel(problem; optimizer)
75+
tn = TensorNetworkModel(instance; optimizer)
7676
sc = contraction_complexity(tn).sc
7777
sc > 28 && error("space complexity too large! got $(sc)")
7878
@debug contraction_complexity(tn)

0 commit comments

Comments
 (0)