Skip to content

Commit 662efd8

Browse files
committed
finish up sector tests
1 parent 94292f2 commit 662efd8

File tree

1 file changed

+95
-27
lines changed

1 file changed

+95
-27
lines changed

test/test_A4.jl

Lines changed: 95 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,104 @@ I = A4Object
22
Istr = TensorKitSectors.type_repr(I)
33
r = size(I)
44

5+
println("----------------------")
6+
println("| Sector tests |")
7+
println("----------------------")
8+
59
@testset "$Istr Basic type properties" verbose = true begin
610
@test eval(Meta.parse(sprint(show, I))) == I
711
@test eval(Meta.parse(TensorKitSectors.type_repr(I))) == I
812
end
913

10-
@testset "$Istr Fusion Category $i" for i in 1:r
11-
objects = I.(i, i, MTK._get_dual_cache(I)[2][i, i])
12-
13-
@testset "Basic properties" begin
14-
s = rand(objects, 3)
15-
@test eval(Meta.parse(sprint(show, s[1]))) == s[1]
16-
@test @constinferred(hash(s[1])) == hash(deepcopy(s[1]))
17-
@test isone(@constinferred(one(s[1])))
18-
@constinferred dual(s[1])
19-
@constinferred dim(s[1])
20-
@constinferred frobeniusschur(s[1])
21-
@constinferred Bsymbol(s...)
22-
@constinferred Fsymbol(s..., s...)
14+
@testset "$Istr: Value iterator" begin
15+
@test eltype(values(I)) == I
16+
@test_throws ArgumentError one(I)
17+
sprev = I(1, 1, 1) # first in SectorValues
18+
for (i, s) in enumerate(values(I))
19+
@test !isless(s, sprev) # confirm compatibility with sort order
20+
@test s == @constinferred (values(I)[i])
21+
@test findindex(values(I), s) == i
22+
sprev = s
23+
i >= 10 && break
24+
end
25+
@test I(1, 1, 1) == first(values(I))
26+
@test (@constinferred findindex(values(I), I(1, 1, 1))) == 1
27+
for s in collect(values(I))
28+
@test (@constinferred values(I)[findindex(values(I), s)]) == s
29+
end
30+
end
31+
32+
@testset "$Istr ($i, $j) basic properties" for i in 1:r, j in 1:r
33+
Cii_obs = I.(i, i, MTK._get_dual_cache(I)[2][i, i])
34+
Cij_obs = I.(i, j, MTK._get_dual_cache(I)[2][i, j])
35+
Cji_obs = I.(j, i, MTK._get_dual_cache(I)[2][j, i])
36+
Cjj_obs = I.(j, j, MTK._get_dual_cache(I)[2][j, j])
37+
c, m, mop, d = rand(Cii_obs), rand(Cij_obs), rand(Cji_obs), rand(Cjj_obs)
38+
39+
if i == j
40+
@testset "Basic fusion properties" begin
41+
s = rand(Cii_obs, 3)
42+
@test eval(Meta.parse(sprint(show, s[1]))) == s[1]
43+
@test @constinferred(hash(s[1])) == hash(deepcopy(s[1]))
44+
@test isone(@constinferred(one(s[1])))
45+
u = I.(i, i, MTK._get_dual_cache(I)[1][i])
46+
@test u == @constinferred(leftone(u)) == @constinferred(rightone(u)) ==
47+
@constinferred(one(u))
48+
@test isone(@constinferred(one(s[1])))
49+
@constinferred dual(s[1])
50+
@test dual(s[1]) == I.(i, i, MTK._get_dual_cache(I)[2][i, i][s[1].label])
51+
@constinferred dim(s[1])
52+
@constinferred frobeniusschur(s[1])
53+
@constinferred Bsymbol(s...)
54+
@constinferred Fsymbol(s..., s...)
55+
end
56+
else
57+
@testset "Basic module properties" begin
58+
@test eval(Meta.parse(sprint(show, m))) == m
59+
@test @constinferred(hash(m)) == hash(deepcopy(m))
60+
61+
@test (isone(@constinferred(leftone(m))) && isone(@constinferred(rightone(m))))
62+
@test one(c) == leftone(m) == rightone(mop)
63+
@test one(d) == rightone(m) == leftone(mop)
64+
@test_throws DomainError one(m)
65+
@test_throws DomainError one(mop)
66+
67+
@constinferred dual(m)
68+
@test dual(m) == I.(j, i, MTK._get_dual_cache(I)[2][i, j][m.label])
69+
@test dual(dual(m)) == m
70+
71+
@constinferred dim(m)
72+
@constinferred frobeniusschur(m)
73+
@constinferred Bsymbol(m, mop, c)
74+
@constinferred Fsymbol(mop, m, mop, mop, d, c)
75+
end
76+
77+
@testset "$Istr Fusion rules" begin
78+
argerr = ArgumentError("invalid fusion channel")
79+
# forbidden fusions
80+
for obs in [(c, d), (d, c), (m, m), (mop, mop), (d, m), (m, c), (mop, d), (c, mop)]
81+
@test_throws AssertionError("a.j == b.i") isempty((obs...))
82+
@test_throws argerr Nsymbol(obs..., rand([c, m, mop, d]))
83+
end
84+
85+
# allowed fusions
86+
for obs in [(c, c), (d, d), (m, mop), (mop, m), (c, m), (mop, c), (m, d), (d, mop)]
87+
@test !isempty((obs...))
88+
end
89+
90+
@test Nsymbol(c, one(c), c) == Nsymbol(d, one(d), d) == 1
91+
92+
@test_throws argerr Nsymbol(m, mop, d)
93+
@test_throws argerr Nsymbol(mop, m, c)
94+
@test_throws argerr Fsymbol(m, mop, m, mop, c, d)
95+
end
2396
end
2497
end
2598

99+
println("-----------------------------")
100+
println("| F-symbol data tests |")
101+
println("-----------------------------")
102+
26103
for i in 1:r, j in 1:r
27104
@testset "Unitarity of $Istr F-move ($i, $j)" begin
28105
if i == j
@@ -46,7 +123,7 @@ for i in 1:r, j in 1:r
46123
@testset "Unitarity of right module F-move ($i, $j)" begin
47124
@test unitarity_test(mod_objects, right_fusion_objects, right_fusion_objects)
48125
end
49-
126+
50127
# C x M x D -> M or D x Mop x C -> Mop
51128
@testset "Unitarity of bimodule F-move ($i, $j)" begin
52129
@test unitarity_test(left_fusion_objects, mod_objects, right_fusion_objects)
@@ -92,23 +169,14 @@ end
92169
end
93170
end
94171

95-
@testset "$Istr ($i, $j) units and duals" for i in 1:r, j in 1:r
96-
Cij_obs = I.(i, j, MTK._get_dual_cache(I)[2][i, j])
97-
98-
s = rand(Cij_obs)
99-
@test eval(Meta.parse(sprint(show, s))) == s
100-
@test @constinferred(hash(s)) == hash(deepcopy(s))
101-
@test i == j ? isone(@constinferred(one(s))) :
102-
(isone(@constinferred(leftone(s))) && isone(@constinferred(rightone(s))))
103-
@constinferred dual(s)
104-
@test dual(s) == I.(j, i, MTK._get_dual_cache(I)[2][i, j][s.label])
105-
@test dual(dual(s)) == s
106-
end
172+
println("-----------------------------")
173+
println("| F-symbol data tests |")
174+
println("-----------------------------")
107175

108176
@testset "$Istr ($i, $j) left and right units" for i in 1:r, j in 1:r
109177
Cij_obs = I.(i, j, MTK._get_dual_cache(I)[2][i, j])
110178

111-
s = rand(Cij_obs, 1)[1]
179+
s = rand(Cij_obs)
112180
sp = Vect[I](s => 1)
113181
W = sp sp
114182
for T in (Float32, ComplexF64)

0 commit comments

Comments
 (0)