Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedikt Kloss committed Jan 24, 2024
1 parent 3aa639f commit f96763c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions test/test_treetensornetworks/test_expect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ using Test
res_a = expect("Sz", a)
res_b = expect(b, "Sz")
res_a = [res_a[v] for v in vertices(a)]
@test res_a res_b rtol=1e-6
@test res_a res_b rtol = 1e-6
end

@testset "TTN expect" begin
tooth_lengths = fill(5, 6)
c = named_comb_tree(tooth_lengths)
s = siteinds("S=1/2", c)
d = Dict()
magnetization = Dict()
for (i, v) in enumerate(vertices(s))
d[v] = isodd(i) ? "Up" : "Dn"
magnetization[v] = isodd(i) ? 0.5 : -0.5
end
states = v -> d[v]
state = TTN(s, states)
res=expect("Sz", state) # just testing that this doesn't go via expect for arbitrary tensor networks.
@test all([isapprox(res[v], magnetization[v],atol=1e-8) for v in vertices(s)])
tooth_lengths = fill(5, 6)
c = named_comb_tree(tooth_lengths)
s = siteinds("S=1/2", c)
d = Dict()
magnetization = Dict()
for (i, v) in enumerate(vertices(s))
d[v] = isodd(i) ? "Up" : "Dn"
magnetization[v] = isodd(i) ? 0.5 : -0.5
end
states = v -> d[v]
state = TTN(s, states)
res = expect("Sz", state) # just testing that this doesn't go via expect for arbitrary tensor networks.
@test all([isapprox(res[v], magnetization[v]; atol=1e-8) for v in vertices(s)])
end

nothing

0 comments on commit f96763c

Please sign in to comment.