Skip to content

Commit

Permalink
Define sector_type (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogauthe authored Dec 2, 2024
1 parent 2126c98 commit ab95c82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/abstractsector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ function label_fusion_rule(sector_type::Type{<:AbstractSector}, l1, l2)
end

# ================================ GradedUnitRanges interface ==================================
GradedUnitRanges.sector_type(S::Type{<:AbstractSector}) = S

# tensor_product interface
function GradedUnitRanges.fuse_blocklengths(
l1::LabelledInteger{<:Integer,<:AbstractSector},
Expand Down
6 changes: 5 additions & 1 deletion test/test_simple_sectors.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@eval module $(gensym())
using GradedUnitRanges: dual
using GradedUnitRanges: dual, sector_type
using SymmetrySectors:
Fib,
Ising,
Expand All @@ -18,6 +18,8 @@ using Test: @inferred, @test, @testset, @test_throws
@testset "TrivialSector" begin
q = TrivialSector()

@test sector_type(q) === TrivialSector
@test sector_type(typeof(q)) === TrivialSector
@test (@inferred quantum_dimension(q)) == 1
@test q == q
@test trivial(q) == q
Expand All @@ -32,6 +34,8 @@ using Test: @inferred, @test, @testset, @test_throws
q2 = U1(2)
q3 = U1(3)

@test sector_type(q1) === U1{Int}
@test sector_type(typeof(q1)) === U1{Int}
@test quantum_dimension(q1) == 1
@test quantum_dimension(q2) == 1
@test (@inferred quantum_dimension(q1)) == 1
Expand Down

0 comments on commit ab95c82

Please sign in to comment.