Skip to content

Commit a8989da

Browse files
lkdvosclaude
andcommitted
Test named product sectors through the generic tests instead of a factorized testset
Replace `FermionParity ⊠ U1Irrep ⊠ SU2Irrep` in the sector list by a named Hubbard-like product sector, and drop the testset comparing with the unfactorized manipulations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent fdf1217 commit a8989da

3 files changed

Lines changed: 19 additions & 55 deletions

File tree

‎src/fusiontrees/producttrees.jl‎

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,11 @@ end
5353
unpartition(::Type{ProductSector{T}}, g, a) where {T} =
5454
ProductSector{T}(interleave(T, factortuple(g), factortuple(a)))
5555

56-
headsector(s::ProductSector) =
57-
ismixedproduct(typeof(s)) ? first(partitionfactors(s)) : firstfactor(s)
58-
tailsector(s::ProductSector) =
59-
ismixedproduct(typeof(s)) ? last(partitionfactors(s)) : otherfactors(s)
60-
headsectortype(::Type{I}) where {I <: ProductSector} =
61-
ismixedproduct(I) ? first(partitionfactortypes(I)) : firstfactortype(I)
62-
tailsectortype(::Type{I}) where {I <: ProductSector} =
63-
ismixedproduct(I) ? last(partitionfactortypes(I)) : otherfactorstype(I)
64-
joinsectors(::Type{I}, h, t) where {I <: ProductSector} =
65-
ismixedproduct(I) ? unpartition(I, h, t) : h ⊠ t
56+
headsector(s::ProductSector) = ismixedproduct(typeof(s)) ? first(partitionfactors(s)) : firstfactor(s)
57+
tailsector(s::ProductSector) = ismixedproduct(typeof(s)) ? last(partitionfactors(s)) : otherfactors(s)
58+
headsectortype(::Type{I}) where {I <: ProductSector} = ismixedproduct(I) ? first(partitionfactortypes(I)) : firstfactortype(I)
59+
tailsectortype(::Type{I}) where {I <: ProductSector} = ismixedproduct(I) ? last(partitionfactortypes(I)) : otherfactorstype(I)
60+
joinsectors(::Type{I}, h, t) where {I <: ProductSector} = ismixedproduct(I) ? unpartition(I, h, t) : h ⊠ t
6661

6762
# named products are split and joined as the corresponding `ProductSector`
6863
productsectortype(::Type{NamedSector{NamedTuple{K, T}}}) where {K, T} = ProductSector{T}
@@ -90,9 +85,10 @@ function headtail(f::FusionTree)
9085
return maptree(headsector, f, vertices_h), maptree(tailsector, f, vertices_t)
9186
end
9287
function jointree(::Type{I}, h::FusionTree, t::FusionTree) where {I}
93-
vertices = h.vertices
94-
if FusionStyle(I) isa GenericFusion && length(h) > 1
88+
vertices = if FusionStyle(I) isa GenericFusion && length(h) > 1
9589
vertices = map((μ, ν, n) -> ν + (μ - 1) * n, h.vertices, t.vertices, vertexmultiplicities(t))
90+
else
91+
h.vertices
9692
end
9793
lift(a, b) = joinsectors(I, a, b)
9894
return fusiontreetype(I, length(h))(
@@ -103,24 +99,23 @@ end
10399

104100
# the canonical order of a product block is that of the Kronecker product of the head and tail
105101
# blocks, with the head running fastest
106-
productblock(::Type{I}, head::FusionTreeBlock, tail::FusionTreeBlock) where {I} = FusionTreeBlock(
107-
vec(
108-
[
109-
(jointree(I, h₁, t₁), jointree(I, h₂, t₂))
110-
for (h₁, h₂) in fusiontrees(head), (t₁, t₂) in fusiontrees(tail)
111-
]
112-
)
113-
)
102+
function productblock(::Type{I}, head::FusionTreeBlock, tail::FusionTreeBlock) where {I}
103+
trees = [(jointree(I, h₁, t₁), jointree(I, h₂, t₂)) for (h₁, h₂) in fusiontrees(head), (t₁, t₂) in fusiontrees(tail)]
104+
return FusionTreeBlock(vec(trees))
105+
end
106+
114107
function FusionTreeBlock{I}(
115108
uncoupled::Tuple{NTuple{N₁, I}, NTuple{N₂, I}},
116109
isdual::Tuple{NTuple{N₁, Bool}, NTuple{N₂, Bool}};
117110
sizehint::Int = 0
118111
) where {I <: ProductSectorType, N₁, N₂}
119112
# a block of `UniqueFusion` sectors has a single tree pair, in any order
120113
FusionStyle(I) isa UniqueFusion && return fusiontreeblock(I, uncoupled, isdual; sizehint)
114+
121115
# the tail holds the `UniqueFusion` factors of a mixed product, which are cheaper to construct
122116
tail = FusionTreeBlock{tailsectortype(I)}(map.(tailsector, uncoupled), isdual)
123117
isempty(tail) && return FusionTreeBlock(Vector{fusiontreetype(I, N₁, N₂)}())
118+
124119
head = FusionTreeBlock{headsectortype(I)}(map.(headsector, uncoupled), isdual)
125120
return productblock(I, head, tail)
126121
end
@@ -141,8 +136,7 @@ function factor_transform(transform::F, ::Type{T}, src::FusionTreeBlock) where {
141136
return FusionTreeBlock(map(first, dst)) => LinearAlgebra.diagm(T[last(d) for d in dst])
142137
end
143138

144-
# apply `transform` to the block `src` through its head and tail, with the recoupling
145-
# matrix with scalar type `T`
139+
# apply `transform` to the block `src` through its head and tail, with the recoupling matrix with scalar type `T`
146140
function product_transform(transform::F, ::Type{T}, src::FusionTreeBlock{I}) where {F, T, I}
147141
if FusionStyle(I) isa UniqueFusion
148142
return factor_transform(transform, T, src)

‎test/setup.jl‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ uniquefusionsectorlist = (
158158
)
159159
simplefusionsectorlist = (
160160
CU1Irrep, SU2Irrep, FibonacciAnyon, IsingAnyon,
161-
FermionParity ⊠ U1Irrep ⊠ SU2Irrep, FermionParity ⊠ SU2Irrep ⊠ SU2Irrep,
161+
@NamedSector{f::FermionParity, s::SU2Irrep, c::U1Irrep}, # named Hubbard-like
162+
FermionParity ⊠ SU2Irrep ⊠ SU2Irrep,
162163
ZNElement{6, 3} ⊠ SU2Irrep, # complex F symbols, anyonic braiding
163164
Z3Element{1} ⊠ FibonacciAnyon ⊠ FibonacciAnyon, # complex F symbols, no braiding
164165
)

‎test/symmetries/doubletree.jl‎

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using TensorKitSectors
1212

1313
@timedtestset "Double fusion trees for $(TensorKit.type_repr(I))" verbose = true for I in (fast_tests ? fast_sectorlist : sectorlist)
1414
Istr = TensorKit.type_repr(I)
15-
N = I <: ProductSector ? 3 : 4
15+
N = I <: Union{ProductSector, NamedSector} ? 3 : 4
1616

1717
if UnitStyle(I) isa SimpleUnit
1818
out = random_fusion(I, Val(N))
@@ -235,37 +235,6 @@ using TensorKitSectors
235235
end
236236
end
237237

238-
I <: ProductSector && FusionStyle(I) isa MultipleFusion && @testset "Double fusion tree: factorized product sector" begin
239-
# the factorized manipulations agree with the manipulations of the full product sector
240-
i0 = rand(1:(2N))
241-
p = mod1.(i0 .+ (1:(2N)), 2N)
242-
p′ = tuple(getindex.(Ref(vcat(1:N, (2N):-1:(N + 1))), p)...)
243-
n = rand(0:(2N))
244-
pt = (p′[1:n], p′[(2N):-1:(n + 1)])
245-
manipulations = Any[(x -> transpose(x, pt), x -> TK.fstranspose((x, pt)))]
246-
if BraidingStyle(I) isa HasBraiding
247-
p = (randperm(2N)...,)
248-
pb = (p[1:n], p[(n + 1):(2N)])
249-
levels = (ntuple(identity, N), ntuple(i -> i + N, N))
250-
push!(manipulations, (x -> TK.braid(x, pb, levels), x -> TK.fsbraid((x, pb, levels))))
251-
end
252-
# the same block with named factors
253-
T = I.parameters[1]
254-
Iₙ = NamedSector{NamedTuple{ntuple(i -> Symbol(:s, i), fieldcount(T)), T}}
255-
nametree(f) = FusionTree(map(Iₙ, f.uncoupled), Iₙ(f.coupled), f.isdual, map(Iₙ, f.innerlines), f.vertices)
256-
nametrees(block) = map(((f₁, f₂),) -> (nametree(f₁), nametree(f₂)), fusiontrees(block))
257-
srcₙ = FusionTreeBlock(nametrees(src))
258-
for (manipulation, unfactorized) in manipulations
259-
dst, U = manipulation(src)
260-
dst′, U′ = unfactorized(src)
261-
@test fusiontrees(dst) == fusiontrees(dst′)
262-
@test U ≈ U′
263-
dstₙ, Uₙ = manipulation(srcₙ)
264-
@test fusiontrees(dstₙ) == nametrees(dst)
265-
@test Uₙ ≈ U
266-
end
267-
end
268-
269238
@testset "Double fusion tree: planar trace" begin
270239
if FusionStyle(I) isa UniqueFusion
271240
f1, f1 = src

0 commit comments

Comments
 (0)