Skip to content

Commit

Permalink
fix fuse_blocklengths(::EmptyCategory)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogauthe committed Sep 17, 2024
1 parent 933c0d4 commit de8759d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 8 additions & 6 deletions NDTensors/src/lib/Sectors/src/abstractcategory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ function GradedAxes.fuse_blocklengths(
end

function GradedAxes.fuse_blocklengths(
::SymmetryStyle,
l1::LabelledNumbers.LabelledInteger{<:Integer,<:Sectors.AbstractCategory},
l2::LabelledNumbers.LabelledInteger{<:Integer,<:Sectors.AbstractCategory},
::SymmetryStyle, l1::LabelledNumbers.LabelledInteger, l2::LabelledNumbers.LabelledInteger
)
fused = LabelledNumbers.label(l1) LabelledNumbers.label(l2)
v =
Expand All @@ -96,14 +94,18 @@ function GradedAxes.fuse_blocklengths(
end

function GradedAxes.fuse_blocklengths(
::AbelianGroup,
l1::LabelledNumbers.LabelledInteger{<:Integer,<:Sectors.AbstractCategory},
l2::LabelledNumbers.LabelledInteger{<:Integer,<:Sectors.AbstractCategory},
::AbelianGroup, l1::LabelledNumbers.LabelledInteger, l2::LabelledNumbers.LabelledInteger
)
fused = LabelledNumbers.label(l1) LabelledNumbers.label(l2)
return LabelledNumbers.labelled(l1 * l2, fused)
end

function GradedAxes.fuse_blocklengths(
::EmptyCategory, l1::LabelledNumbers.LabelledInteger, l2::LabelledNumbers.LabelledInteger
)
return LabelledNumbers.labelled(l1 * l2, sector())
end

# cast to range
to_graded_axis(c::AbstractCategory) = to_graded_axis(LabelledNumbers.labelled(1, c))
to_graded_axis(l::LabelledNumbers.LabelledInteger) = GradedAxes.gradedrange([l])
Expand Down
3 changes: 3 additions & 0 deletions NDTensors/src/lib/Sectors/test/test_category_product.jl
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ end
@test typeof(s) == typeof(sector(()))
@test typeof(s) == typeof(sector((;))) # empty NamedTuple is cast to Tuple{}

g0 = gradedrange([s => 2])
@test gradedisequal((@inferred fusion_product(g0, g0)), gradedrange([s => 4]))

@test (@inferred s × U1(1)) == sector(U1(1))
@test (@inferred s × sector(U1(1))) == sector(U1(1))
@test (@inferred s × sector(; A=U1(1))) == sector(; A=U1(1))
Expand Down

0 comments on commit de8759d

Please sign in to comment.