Skip to content

Commit 7440149

Browse files
author
Jack Dunham
committed
test file formatting
1 parent 6161cb3 commit 7440149

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

test/test_beliefpropagation.jl

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
using Dictionaries: Dictionary
22
using ITensorBase: Index
3-
using ITensorNetworksNext: ITensorNetworksNext, BeliefPropagationCache, TensorNetwork, adapt_messages, default_message, default_messages, edge_scalars, messages, setmessages!, factors, freenergy,
4-
partitionfunction
3+
using ITensorNetworksNext:
4+
BeliefPropagationCache,
5+
ITensorNetworksNext,
6+
TensorNetwork,
7+
adapt_messages,
8+
default_message,
9+
default_messages,
10+
edge_scalars,
11+
factors,
12+
messages,
13+
partitionfunction,
14+
setmessages!
515
using Graphs: edges, vertices
616
using NamedGraphs.NamedGraphGenerators: named_grid, named_comb_tree
717
using NamedGraphs.GraphsExtensions: arranged_edges, incident_edges
@@ -15,29 +25,30 @@ using Test: @test, @testset
1525
l = Dict(e => Index(2) for e in edges(g))
1626
l = merge(l, Dict(reverse(e) => l[e] for e in edges(g)))
1727
tn = TensorNetwork(g) do v
18-
is = map(e -> l[e], incident_edges(g, v))
19-
return randn(Tuple(is))
28+
is = map(e -> l[e], incident_edges(g, v))
29+
return randn(Tuple(is))
2030
end
2131

2232
bpc = BeliefPropagationCache(tn)
2333
bpc = ITensorNetworksNext.update(bpc; maxiter = 1)
2434
z_bp = partitionfunction(bpc)
2535
z_exact = reduce(*, [tn[v] for v in vertices(g)])[]
26-
@test abs(z_bp - z_exact) <= 1e-14
36+
@test abs(z_bp - z_exact) <= 1.0e-14
2737

2838
#Tree of tensors
2939
dims = (4, 3)
3040
g = named_comb_tree(dims)
3141
l = Dict(e => Index(3) for e in edges(g))
3242
l = merge(l, Dict(reverse(e) => l[e] for e in edges(g)))
3343
tn = TensorNetwork(g) do v
34-
is = map(e -> l[e], incident_edges(g, v))
35-
return randn(Tuple(is))
44+
is = map(e -> l[e], incident_edges(g, v))
45+
return randn(Tuple(is))
3646
end
3747

3848
bpc = BeliefPropagationCache(tn)
3949
bpc = ITensorNetworksNext.update(bpc; maxiter = 10)
4050
z_bp = partitionfunction(bpc)
4151
z_exact = reduce(*, [tn[v] for v in vertices(g)])[]
42-
@test abs(z_bp - z_exact) <= 1e-14
43-
end
52+
@test abs(z_bp - z_exact) <= 1.0e-14
53+
end
54+

0 commit comments

Comments
 (0)