Skip to content

Commit 648bc28

Browse files
committed
rename EmptyCategory to EmptyCategoryStyle
1 parent b3e6008 commit 648bc28

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

NDTensors/src/lib/Sectors/src/abstractcategory.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function quantum_dimension(::SymmetryStyle, c::AbstractCategory)
4343
end
4444

4545
quantum_dimension(::AbelianGroup, ::AbstractCategory) = 1
46-
quantum_dimension(::EmptyCategory, ::AbstractCategory) = 1
46+
quantum_dimension(::EmptyCategoryStyle, ::AbstractCategory) = 1
4747
quantum_dimension(::SymmetryStyle, g::AbstractUnitRange) = sum(block_dimensions(g))
4848
quantum_dimension(::AbelianGroup, g::AbstractUnitRange) = length(g)
4949

@@ -64,7 +64,7 @@ function fusion_rule(::AbelianGroup, c1::C, c2::C) where {C<:AbstractCategory}
6464
return C(label_fusion_rule(C, category_label(c1), category_label(c2)))
6565
end
6666

67-
function fusion_rule(::EmptyCategory, l1::LabelledInteger, l2::LabelledInteger)
67+
function fusion_rule(::EmptyCategoryStyle, l1::LabelledInteger, l2::LabelledInteger)
6868
return labelled(l1 * l2, sector())
6969
end
7070

@@ -97,7 +97,7 @@ function GradedAxes.fuse_blocklengths(
9797
end
9898

9999
function GradedAxes.fuse_blocklengths(
100-
::EmptyCategory, l1::LabelledInteger, l2::LabelledInteger
100+
::EmptyCategoryStyle, l1::LabelledInteger, l2::LabelledInteger
101101
)
102102
return labelled(l1 * l2, sector())
103103
end

NDTensors/src/lib/Sectors/src/category_product.jl

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ CategoryProduct(c::CategoryProduct) = _CategoryProduct(categories(c))
1515

1616
categories(s::CategoryProduct) = s.cats
1717

18-
const EmptyCategoryProduct = CategoryProduct{Tuple{}}
18+
const EmptyCategory = CategoryProduct{Tuple{}}
1919

2020
# ================================= Sectors interface ====================================
2121
function SymmetryStyle(c::CategoryProduct)
22-
return reduce(combine_styles, map(SymmetryStyle, categories(c)); init=EmptyCategory())
22+
return reduce(
23+
combine_styles, map(SymmetryStyle, categories(c)); init=EmptyCategoryStyle()
24+
)
2325
end
2426

2527
function quantum_dimension(::NonAbelianGroup, s::CategoryProduct)
@@ -151,6 +153,13 @@ end
151153

152154
# ==================================== Fusion rules ======================================
153155
# generic case: fusion returns a GradedAxes, even for fusion with Empty
156+
function fusion_rule(style::SymmetryStyle, c1::CategoryProduct, c2::AbstractCategory)
157+
return fusion_rule(style, c1, CategoryProduct(c2))
158+
end
159+
function fusion_rule(style::SymmetryStyle, c1::AbstractCategory, c2::CategoryProduct)
160+
return fusion_rule(style, CategoryProduct(c1), c2)
161+
end
162+
154163
function fusion_rule(::SymmetryStyle, s1::CategoryProduct, s2::CategoryProduct)
155164
return to_gradedrange(categories_fusion_rule(categories(s1), categories(s2)))
156165
end
@@ -161,29 +170,29 @@ function fusion_rule(::AbelianGroup, s1::CategoryProduct, s2::CategoryProduct)
161170
end
162171

163172
# Empty case
164-
function fusion_rule(::EmptyCategory, ::EmptyCategoryProduct, ::EmptyCategoryProduct)
173+
function fusion_rule(::EmptyCategoryStyle, ::EmptyCategory, ::EmptyCategory)
165174
return sector()
166175
end
167176

168-
# EmptyCategory acts as trivial on any AbstractCategory, not just CategoryProduct
169-
function fusion_rule(::SymmetryStyle, ::EmptyCategoryProduct, c::AbstractCategory)
177+
# EmptyCategoryStyle acts as trivial on any AbstractCategory, not just CategoryProduct
178+
function fusion_rule(::SymmetryStyle, ::EmptyCategory, c::AbstractCategory)
170179
return to_gradedrange(c)
171180
end
172-
function fusion_rule(::SymmetryStyle, ::EmptyCategoryProduct, c::CategoryProduct)
181+
function fusion_rule(::SymmetryStyle, c::AbstractCategory, ::EmptyCategory)
173182
return to_gradedrange(c)
174183
end
175-
function fusion_rule(::SymmetryStyle, c::AbstractCategory, ::EmptyCategoryProduct)
184+
function fusion_rule(::SymmetryStyle, ::EmptyCategory, c::CategoryProduct)
176185
return to_gradedrange(c)
177186
end
178-
function fusion_rule(::SymmetryStyle, c::CategoryProduct, ::EmptyCategoryProduct)
187+
function fusion_rule(::SymmetryStyle, c::CategoryProduct, ::EmptyCategory)
179188
return to_gradedrange(c)
180189
end
181190

182191
# abelian case: return Category
183-
fusion_rule(::AbelianGroup, ::EmptyCategoryProduct, c::AbstractCategory) = c
184-
fusion_rule(::AbelianGroup, ::EmptyCategoryProduct, c::CategoryProduct) = c
185-
fusion_rule(::AbelianGroup, c::AbstractCategory, ::EmptyCategoryProduct) = c
186-
fusion_rule(::AbelianGroup, c::CategoryProduct, ::EmptyCategoryProduct) = c
192+
fusion_rule(::AbelianGroup, c::AbstractCategory, ::EmptyCategory) = c
193+
fusion_rule(::AbelianGroup, ::EmptyCategory, c::AbstractCategory) = c
194+
fusion_rule(::AbelianGroup, c::CategoryProduct, ::EmptyCategory) = c
195+
fusion_rule(::AbelianGroup, ::EmptyCategory, c::CategoryProduct) = c
187196

188197
# =============================== Ordered implementation =================================
189198
CategoryProduct(t::Tuple) = _CategoryProduct(t)
@@ -217,7 +226,7 @@ end
217226

218227
CategoryProduct(; kws...) = CategoryProduct((; kws...))
219228

220-
# avoid having 2 different kinds of EmptyCategory: cast empty NamedTuple to Tuple{}
229+
# avoid having 2 different kinds of EmptyCategoryStyle: cast empty NamedTuple to Tuple{}
221230
CategoryProduct(::NamedTuple{()}) = CategoryProduct(())
222231

223232
function CategoryProduct(pairs::Pair...)

NDTensors/src/lib/Sectors/src/symmetry_style.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ abstract type SymmetryStyle end
88
struct AbelianGroup <: SymmetryStyle end
99
struct NonAbelianGroup <: SymmetryStyle end
1010
struct NonGroupCategory <: SymmetryStyle end
11-
struct EmptyCategory <: SymmetryStyle end # CategoryProduct with zero category inside
11+
struct EmptyCategoryStyle <: SymmetryStyle end # CategoryProduct with zero category inside
1212

1313
combine_styles(::AbelianGroup, ::AbelianGroup) = AbelianGroup()
1414
combine_styles(::AbelianGroup, ::NonAbelianGroup) = NonAbelianGroup()
@@ -17,10 +17,10 @@ combine_styles(::NonAbelianGroup, ::AbelianGroup) = NonAbelianGroup()
1717
combine_styles(::NonAbelianGroup, ::NonAbelianGroup) = NonAbelianGroup()
1818
combine_styles(::NonAbelianGroup, ::NonGroupCategory) = NonGroupCategory()
1919
combine_styles(::NonGroupCategory, ::SymmetryStyle) = NonGroupCategory()
20-
combine_styles(::NonGroupCategory, ::EmptyCategory) = NonGroupCategory()
21-
combine_styles(::EmptyCategory, s::SymmetryStyle) = s
22-
combine_styles(s::SymmetryStyle, ::EmptyCategory) = s
23-
combine_styles(::EmptyCategory, ::EmptyCategory) = EmptyCategory()
20+
combine_styles(::NonGroupCategory, ::EmptyCategoryStyle) = NonGroupCategory()
21+
combine_styles(::EmptyCategoryStyle, s::SymmetryStyle) = s
22+
combine_styles(s::SymmetryStyle, ::EmptyCategoryStyle) = s
23+
combine_styles(::EmptyCategoryStyle, ::EmptyCategoryStyle) = EmptyCategoryStyle()
2424

2525
SymmetryStyle(l::LabelledInteger) = SymmetryStyle(label(l))
2626

0 commit comments

Comments
 (0)