Skip to content

Commit 21204c4

Browse files
authored
Refactor unitarity of F-symbol test (#73)
1 parent 5e57667 commit 21204c4

2 files changed

Lines changed: 28 additions & 17 deletions

File tree

test/sectors.jl

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -170,22 +170,7 @@ end
170170

171171
@testsuite "Unitarity of F-move" I -> begin
172172
for a in smallset(I), b in smallset(I), c in smallset(I)
173-
for d in (a, b, c)
174-
es = collect(intersect((a, b), map(dual, (c, dual(d)))))
175-
fs = collect(intersect((b, c), map(dual, (dual(d), a))))
176-
if FusionStyle(I) isa MultiplicityFreeFusion
177-
@test length(es) == length(fs)
178-
F = [Fsymbol(a, b, c, d, e, f) for e in es, f in fs]
179-
else
180-
Fblocks = Vector{Any}()
181-
for e in es, f in fs
182-
Fs = Fsymbol(a, b, c, d, e, f)
183-
push!(Fblocks, reshape(Fs, (size(Fs, 1) * size(Fs, 2), size(Fs, 3) * size(Fs, 4))))
184-
end
185-
F = hvcat(length(fs), Fblocks...)
186-
end
187-
@test isapprox(F' * F, one(F); atol = 1.0e-12, rtol = 1.0e-12)
188-
end
173+
@test F_unitarity_test(a, b, c; atol = 1.0e-12, rtol = 1.0e-12)
189174
end
190175
end
191176

test/testsuite.jl

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Additionally, this test suite exports the following convenience testing utilitie
2424
"""
2525
module SectorTestSuite
2626

27-
export smallset, randsector, hasfusiontensor
27+
export smallset, randsector, hasfusiontensor, F_unitarity_test
2828

2929
using Test
3030
using TestExtras
@@ -104,6 +104,32 @@ function hasfusiontensor(I::Type{<:Sector})
104104
end
105105
end
106106

107+
"""
108+
F_unitarity_test(a::I, b::I, c::I; kwargs...) where {I <: Sector}
109+
110+
Tests the unitarity of the F-symbols for the fusion of `a`, `b`, and `c`.
111+
Returns `true` if the F-symbols are unitary, and `false` otherwise.
112+
"""
113+
function F_unitarity_test(a::I, b::I, c::I; kwargs...) where {I <: Sector}
114+
for d in (a, b, c)
115+
es = collect(intersect((a, b), map(dual, (c, dual(d)))))
116+
fs = collect(intersect((b, c), map(dual, (dual(d), a))))
117+
if FusionStyle(I) isa MultiplicityFreeFusion
118+
@assert length(es) == length(fs)
119+
F = [Fsymbol(a, b, c, d, e, f) for e in es, f in fs]
120+
else
121+
Fblocks = Vector{Any}()
122+
for e in es, f in fs
123+
Fs = Fsymbol(a, b, c, d, e, f)
124+
push!(Fblocks, reshape(Fs, (size(Fs, 1) * size(Fs, 2), size(Fs, 3) * size(Fs, 4))))
125+
end
126+
F = hvcat(length(fs), Fblocks...)
127+
end
128+
isapprox(F' * F, one(F); kwargs...) || return false
129+
end
130+
return true
131+
end
132+
107133
include("sectors.jl")
108134

109135
end # module SectorTestSuite

0 commit comments

Comments
 (0)