Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/abstractsector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ quantum_dimension(::NotAbelianStyle, g::AbstractUnitRange) = sum(block_dimension
function nsymbol(s1::AbstractSector, s2::AbstractSector, s3::AbstractSector)
full_space = fusion_product(s1, s2)
i = findfirst(==(s3), blocklabels(full_space))
isnothing(i) && return labelled(0, s3)
return blocklengths(full_space)[i]
isnothing(i) && return 0
return unlabel(blocklengths(full_space)[i])
end

# =============================== Fusion rule interface ==================================
Expand Down
14 changes: 4 additions & 10 deletions test/test_fusion_rules.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using GradedUnitRanges:
dual, fusion_product, space_isequal, gradedrange, flip, tensor_product
using LabelledNumbers: label
using SymmetrySectors:
⊗,
Fib,
Expand Down Expand Up @@ -29,11 +28,10 @@ using TestExtras: @constinferred
@test (@constinferred z0 ⊗ z0) == z0

q = TrivialSector()
@test (@inferred q ⊗ q) == q
@test (@inferred q ⊗ z0) == z0
@test (@inferred z1 ⊗ q) == z1
@test (@constinferred q ⊗ q) == q
@test (@constinferred q ⊗ z0) == z0
@test (@constinferred z1 ⊗ q) == z1
@test nsymbol(q, q, q) == 1
@test label(nsymbol(q, q, q)) == q

# using GradedUnitRanges interface
@test space_isequal(fusion_product(z0, z0), gradedrange([z0 => 1]))
Expand All @@ -53,12 +51,9 @@ using TestExtras: @constinferred
@test q1 ⊗ q1 == U1(2)
@test q1 ⊗ q2 == U1(3)
@test q2 ⊗ q1 == U1(3)
@test (@inferred q1 ⊗ q2) == q3 # no better way, see Julia PR 23426

@test (@constinferred q1 ⊗ q2) == q3
@test nsymbol(q1, q2, q3) == 1
@test label(nsymbol(q1, q2, q3)) == q3
@test nsymbol(q1, q1, q3) == 0
@test label(nsymbol(q1, q1, q3)) == q3
end

@testset "O2 fusion rules" begin
Expand Down Expand Up @@ -277,7 +272,6 @@ end
)

@test nsymbol(ad8, ad8, ad8) == 2
@test label(nsymbol(ad8, ad8, ad8)) == ad8
end

@testset "Mixed GradedUnitRange - Sector fusion rules" begin
Expand Down
Loading