|
1 | 1 | # Deligne tensor product of different sectors: ⊠ |
2 | 2 | #------------------------------------------------------------------------------# |
3 | | -const SectorTuple = Tuple{Vararg{Sector}} |
| 3 | +const SectorTuple = Tuple{Sector, Vararg{Sector}} |
4 | 4 | const SectorNamedTuple = NamedTuple{<:Any, <:SectorTuple} |
5 | 5 | const AnySectorTuple = Union{SectorTuple, SectorNamedTuple} |
6 | 6 |
|
@@ -35,17 +35,22 @@ ProductSector{NamedTuple{K, V}}(x::Tuple) where {K, V} = ProductSector{NamedTupl |
35 | 35 | const TupleProductSector{T <: SectorTuple} = ProductSector{T} |
36 | 36 | const NamedProductSector{T <: SectorTuple} = ProductSector{<:NamedTuple{<:Any, T}} |
37 | 37 |
|
38 | | -TupleProductSector(s::NamedProductSector) = ProductSector(values(s.sectors)) |
| 38 | +TupleProductSector(s::NamedProductSector) = ProductSector(values(Tuple(s))) |
39 | 39 |
|
40 | 40 | Base.Tuple(a::ProductSector) = Tuple(a.sectors) |
41 | 41 |
|
42 | | -Base.getindex(s::ProductSector, i::Int) = getindex(s.sectors, i) |
43 | | -Base.length(s::ProductSector) = length(s.sectors) |
44 | | -Base.iterate(s::ProductSector, args...) = iterate(s.sectors, args...) |
| 42 | +Base.getindex(s::ProductSector, i::Int) = getindex(Tuple(s), i) |
| 43 | +Base.length(s::ProductSector) = length(Tuple(s)) |
| 44 | +Base.iterate(s::ProductSector, args...) = iterate(Tuple(s), args...) |
45 | 45 | Base.indexed_iterate(s::ProductSector, args...) = Base.indexed_iterate(s.sectors, args...) |
46 | 46 |
|
47 | | -Base.@constprop :aggressive function Base.getproperty(s::NamedProductSector, f::Symbol) |
48 | | - return f === :sectors ? getfield(s, f) : getproperty(s.sectors, f) |
| 47 | +Base.@constprop :aggressive function Base.getproperty(s::ProductSector{<:NamedTuple}, f::Symbol) |
| 48 | + sectors = getfield(s, :sectors) |
| 49 | + if f === :sectors |
| 50 | + return sectors |
| 51 | + else |
| 52 | + return getproperty(sectors, f) |
| 53 | + end |
49 | 54 | end |
50 | 55 | Base.propertynames(s::NamedProductSector) = (:sectors, propertynames(fieldtype(typeof(s), :sectors))...) |
51 | 56 |
|
@@ -111,8 +116,8 @@ function Nsymbol(a::P, b::P, c::P) where {P <: ProductSector} |
111 | 116 | return prod(map(Nsymbol, a.sectors, b.sectors, c.sectors)) |
112 | 117 | end |
113 | 118 |
|
114 | | -_firstsector(x::ProductSector) = x.sectors[1] |
115 | | -_tailsector(x::ProductSector) = ProductSector(Base.tail(Tuple(x.sectors))) |
| 119 | +_firstsector(x::ProductSector) = Base.first(Tuple(x)) |
| 120 | +_tailsector(x::ProductSector) = ProductSector(Base.tail(Tuple(x))) |
116 | 121 |
|
117 | 122 | function Fsymbol(a::P, b::P, c::P, d::P, e::P, f::P) where {P <: ProductSector} |
118 | 123 | heads = map(_firstsector, (a, b, c, d, e, f)) |
@@ -210,8 +215,8 @@ function Asymbol(a::P, b::P, c::P) where {P <: ProductSector} |
210 | 215 | end |
211 | 216 | end |
212 | 217 |
|
213 | | -frobenius_schur_phase(p::ProductSector) = prod(frobenius_schur_phase, p.sectors) |
214 | | -frobenius_schur_indicator(p::ProductSector) = prod(frobenius_schur_indicator, p.sectors) |
| 218 | +frobenius_schur_phase(p::ProductSector) = prod(frobenius_schur_phase, Tuple(p)) |
| 219 | +frobenius_schur_indicator(p::ProductSector) = prod(frobenius_schur_indicator, Tuple(p)) |
215 | 220 |
|
216 | 221 | function fusiontensor(a::P, b::P, c::P) where {P <: ProductSector} |
217 | 222 | heads = map(_firstsector, (a, b, c)) |
@@ -305,7 +310,7 @@ Base.@assume_effects :foldable function _deligneproduct_impl( |
305 | 310 | end |
306 | 311 |
|
307 | 312 | function Base.show(io::IO, P::TupleProductSector) |
308 | | - sectors = P.sectors |
| 313 | + sectors = Tuple(P) |
309 | 314 | compact = get(io, :typeinfo, nothing) === typeof(P) |
310 | 315 | sep = compact ? ", " : " ⊠ " |
311 | 316 | print(io, "(") |
@@ -396,7 +401,7 @@ See Julia issues #29988, #29428, #22363, #28983. |
396 | 401 | Base.show(io::IO, P::Type{<:ProductSector}) = print(io, type_repr(P)) |
397 | 402 | ==============================================================================# |
398 | 403 | function Base.show(io::IO, P::ProductSector{T}) where {T <: Tuple{Vararg{AbstractIrrep}}} |
399 | | - sectors = P.sectors |
| 404 | + sectors = Tuple(P) |
400 | 405 | get(io, :typeinfo, nothing) === typeof(P) || print(io, type_repr(typeof(P))) |
401 | 406 | print(io, "(") |
402 | 407 | for i in 1:length(sectors) |
|
0 commit comments