Skip to content

Commit 09e76e6

Browse files
authored
Tests for shapes of topological data (#64)
* test suites for shapes and fusion ring stuff * separate eltype tests from basic properties * use `can_fuse` instead of checking intersect * update data storage type test * format * extra braiding check * test data types differently * check invalid fusion channels separately from topological data shapes * generalise to multiplicity-free * don't separate invalid fusion channels check from shapes check * check braiding on time * remove one for-loop of checks * bring back splitting invalid fusion channel checks from shapes checks * switch loop order
1 parent 073d7b3 commit 09e76e6

1 file changed

Lines changed: 70 additions & 6 deletions

File tree

‎test/sectors.jl‎

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,33 @@ using TensorKitSectors: TensorKitSectors as TKS
2222
s2 = random_fusion(I, 3)
2323
s2c = first(⊗(s2...))
2424
e, f = first(⊗(s2[1], s2[2])), first(⊗(s2[2], s2[3]))
25-
F = @testinferred Fsymbol(s2..., s2c, e, f)
26-
@test eltype(F) === @testinferred fusionscalartype(I)
25+
@testinferred Fsymbol(s2..., s2c, e, f)
2726
if BraidingStyle(I) isa HasBraiding
28-
R = @testinferred Rsymbol(s..., sc)
29-
@test eltype(R) === @testinferred braidingscalartype(I)
30-
if FusionStyle(I) === SimpleFusion()
27+
@testinferred Rsymbol(s..., sc)
28+
end
29+
end
30+
31+
@testsuite "Element and data types of topological data" I -> begin
32+
a, b, c = random_fusion(I, 3)
33+
d, e, f = first(⊗(a, b, c)), first(⊗(a, b)), first(⊗(b, c))
34+
F = Fsymbol(a, b, c, d, e, f)
35+
Ftype = @testinferred fusionscalartype(I)
36+
@test eltype(F) === Ftype
37+
@test F isa (FusionStyle(I) isa MultiplicityFreeFusion ? Ftype : AbstractArray{Ftype, 4})
38+
if BraidingStyle(I) isa HasBraiding
39+
a, b = random_fusion(I, 2)
40+
R = Rsymbol(a, b, first(⊗(a, b)))
41+
Rtype = @testinferred braidingscalartype(I)
42+
@test eltype(R) === Rtype
43+
if FusionStyle(I) isa MultiplicityFreeFusion
3144
@test typeof(R * F) <: @testinferred sectorscalartype(I)
45+
@test R isa Rtype
3246
else
3347
@test Base.promote_op(*, eltype(R), eltype(F)) <: @testinferred sectorscalartype(I)
48+
@test R isa AbstractArray{Rtype, 2}
3449
end
3550
else
36-
if FusionStyle(I) === SimpleFusion()
51+
if FusionStyle(I) isa MultiplicityFreeFusion
3752
@test typeof(F) <: @testinferred sectorscalartype(I)
3853
else
3954
@test eltype(F) <: @testinferred sectorscalartype(I)
@@ -71,6 +86,55 @@ end
7186
end
7287
end
7388

89+
@testsuite "Nsymbol error handling" I -> begin
90+
r = randsector(I)
91+
for a in smallset(I), b in smallset(I)
92+
can_fuse(a, b) || @test_throws ArgumentError Nsymbol(a, b, r)
93+
end
94+
end
95+
96+
@testsuite "Shapes of topological data" I -> begin
97+
# shape of data from multiplicities
98+
for a in smallset(I), b in smallset(I)
99+
can_fuse(a, b) || continue
100+
for c in smallset(I)
101+
can_fuse(b, c) || continue
102+
for f in ⊗(b, c), e in ⊗(a, b) # guaranteed can_fuse
103+
Nabe, Nbcf = Nsymbol(a, b, e), Nsymbol(b, c, f)
104+
for d in ⊗(a, b, c)
105+
F_size = FusionStyle(I) isa MultiplicityFreeFusion ? () : (Nabe, Nsymbol(e, c, d), Nbcf, Nsymbol(a, f, d))
106+
@test size(Fsymbol(a, b, c, d, e, f)) == F_size
107+
end
108+
end
109+
end
110+
end
111+
112+
if BraidingStyle(I) isa HasBraiding
113+
for a in smallset(I), b in smallset(I), c in smallset(I)
114+
R_size = FusionStyle(I) isa MultiplicityFreeFusion ? () : (Nsymbol(a, b, c), Nsymbol(b, a, c))
115+
@test size(Rsymbol(a, b, c)) == R_size
116+
end
117+
end
118+
end
119+
120+
# https://arxiv.org/pdf/2507.07023v2#=&page=9
121+
@testsuite "Fusion ring properties" I -> begin
122+
for a in smallset(I), b in smallset(I)
123+
for c in smallset(I), d in smallset(I) # associativity
124+
L = sum(e -> Nsymbol(a, b, e) * Nsymbol(e, c, d), intersect(⊗(a, b), ⊗(d, dual(c))); init = zero(Int))
125+
R = sum(f -> Nsymbol(b, c, f) * Nsymbol(a, f, d), intersect(⊗(b, c), ⊗(dual(a), d)); init = zero(Int))
126+
@test L == R
127+
end
128+
for c in ⊗(a, b) # Frobenius reciprocity
129+
@test Nsymbol(a, b, c) == Nsymbol(c, dual(b), a) == Nsymbol(dual(c), a, dual(b)) ==
130+
Nsymbol(dual(b), dual(a), dual(c)) == Nsymbol(b, dual(c), dual(a)) == Nsymbol(dual(a), c, b)
131+
if BraidingStyle(I) isa HasBraiding
132+
@test Nsymbol(a, b, c) == Nsymbol(b, a, c)
133+
end
134+
end
135+
end
136+
end
137+
74138
@testsuite "Fusion and dimensions" I -> begin
75139
for a in smallset(I), b in smallset(I)
76140
cs = a ⊗ b

0 commit comments

Comments
 (0)