Skip to content

Commit c16e337

Browse files
Jutholkdvos
andauthored
end of the ends (#36)
* end of the ends * wack the intruder * bump that version * one more consistency update * format docstrings * remove unused exception * share docs of fusion and braiding style * more docstring format * improve leftrightunit doc strings * more runic style in doc strings * more runic style in doc strings2 * some more missing type_reprs * move and document type_repr * make type_repr public --------- Co-authored-by: Lukas Devos <ldevos98@gmail.com>
1 parent eb97430 commit c16e337

File tree

11 files changed

+91
-57
lines changed

11 files changed

+91
-57
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TensorKitSectors"
22
uuid = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"
33
authors = ["Lukas Devos", "Jutho Haegeman"]
4-
version = "0.3.0"
4+
version = "0.3.1"
55

66
[deps]
77
HalfIntegers = "f0d1745a-41c9-11e9-1dd9-e5d34d218721"

src/TensorKitSectors.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ export ⊠, ⊗, ×
3737
export Cyclic, ℤ, ℤ₂, ℤ₃, ℤ₄, U₁, SU, SU₂, Dihedral, D₃, D₄, CU₁
3838
export fℤ₂, fU₁, fSU₂
3939

40+
# public
41+
# ------
42+
@static if VERSION >= v"1.11.0-DEV.469"
43+
eval(Expr(:public, :type_repr))
44+
end
45+
4046
# imports
4147
# -------
4248
using Base: SizeUnknown, HasLength, IsInfinite

src/anyons.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ useful for testing.
1111
"""
1212
struct PlanarTrivial <: Sector end
1313

14+
type_repr(::Type{PlanarTrivial}) = "PlanarTrivial"
15+
1416
Base.IteratorSize(::Type{SectorValues{PlanarTrivial}}) = HasLength()
1517
Base.length(::SectorValues{PlanarTrivial}) = 1
1618
Base.iterate(::SectorValues{PlanarTrivial}, i = 0) = i == 0 ? (PlanarTrivial(), 1) : nothing
@@ -54,6 +56,8 @@ struct FibonacciAnyon <: Sector
5456
end
5557
end
5658

59+
type_repr(::Type{FibonacciAnyon}) = "FibonacciAnyon"
60+
5761
Base.IteratorSize(::Type{SectorValues{FibonacciAnyon}}) = HasLength()
5862
Base.length(::SectorValues{FibonacciAnyon}) = 2
5963
function Base.iterate(::SectorValues{FibonacciAnyon}, i = 0)
@@ -172,6 +176,8 @@ struct IsingAnyon <: Sector
172176
end
173177
end
174178

179+
type_repr(::Type{IsingAnyon}) = "IsingAnyon"
180+
175181
const all_isinganyons = (IsingAnyon(:I), IsingAnyon(), IsingAnyon())
176182

177183
Base.IteratorSize(::Type{SectorValues{IsingAnyon}}) = HasLength()

src/fermions.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""
2-
FermionParity <: Sector
2+
struct FermionParity <: Sector
3+
FermionParity(isodd::Bool)
34
4-
Represents sectors with fermion parity. The fermion parity is a ℤ₂ quantum number that
5+
Represents sectors with fermion parity. The fermion parity is a ``ℤ₂`` quantum number that
56
yields an additional sign when two odd fermions are exchanged, corresponding to a
67
[`BraidingStyle`](@ref) that is `Fermionic()`.
78

src/groupelements.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# associator given by a 3-cocycle.
33
#------------------------------------------------------------------------------#
44
"""
5-
abstract type AbstractGroupElement{G<:Group} <: Sector end
5+
abstract type AbstractGroupElement{G <: Group} <: Sector
66
77
Abstract supertype for sectors which corresponds to group elements of a group `G`.
88
@@ -14,7 +14,7 @@ All group elements have [`FusionStyle`](@ref) equal to `UniqueFusion()`.
1414
Furthermore, the [`BraidingStyle`](@ref) is set to `NoBraiding()`, although this can be
1515
overridden by a concrete implementation of `AbstractGroupElement`.
1616
17-
For the fusion structure, a specific `SomeGroupElement<:AbstractGroupElement{SomeGroup}`
17+
For the fusion structure, a specific `SomeGroupElement <: AbstractGroupElement{SomeGroup}`
1818
should only implement the following methods
1919
```julia
2020
Base.:*(c1::GroupElement, c2::GroupElement) -> GroupElement
@@ -60,10 +60,10 @@ struct ElementTable end
6060
"""
6161
const GroupElement
6262
63-
A constant of a singleton type used as `GroupElement[G]` or `GroupElement[G,ω]` with `G<:Group`
64-
a type of group, to construct or obtain a concrete subtype of `AbstractElement{G}`
65-
that implements the data structure used to represent elements of the group `G`, possibly
66-
with a second argument `ω` that specifies the associated 3-cocycle.
63+
A constant of a singleton type used as `GroupElement[G]` or `GroupElement[G, ω]` with
64+
`G <: Group` a type of group, to construct or obtain a concrete subtype of
65+
`AbstractElement{G}` that implements the data structure used to represent elements of the
66+
group `G`, possibly with a second argument `ω` that specifies the associated 3-cocycle.
6767
"""
6868
const GroupElement = ElementTable()
6969

@@ -92,11 +92,12 @@ end
9292
ZNElement{N, p}(n::Integer)
9393
GroupElement[ℤ{N}, p](n::Integer)
9494
95-
Represents an element of the group ``ℤ_N`` for some value of `N<64`. (We need `2*(N-1) <= 127`
96-
in order for `a ⊗ b` to work correctly.) For `N` equals `2`, `3` or `4`, `ℤ{N}` can be replaced
97-
by `ℤ₂`, `ℤ₃`, `ℤ₄`. An arbitrary `Integer` `n` can be provided to the constructor, but only
98-
the value `mod(n, N)` is relevant. The second type parameter `p` should also be specified as
99-
an integer ` 0 <= p < N` and specifies the 3-cocycle, which is then being given by
95+
Represents an element of the group ``ℤ_N`` for some value of `N < 64`. (We need
96+
`2 * (N - 1) <= 127` in order for `a ⊗ b` to work correctly.) For `N` equals `2`, `3` or
97+
`4`, `ℤ{N}` can be replaced by `ℤ₂`, `ℤ₃`, `ℤ₄`. An arbitrary `Integer` `n` can be provided
98+
to the constructor, but only the value `mod(n, N)` is relevant. The second type parameter
99+
`p` should also be specified as an integer ` 0 <= p < N` and specifies the 3-cocycle, which
100+
is then being given by
100101
101102
```julia
102103
cocycle(a, b, c) = cispi(2 * p * a.n * (b.n + c.n - mod(b.n + c.n, N)) / N))

src/groups.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Groups
22
#------------------------------------------------------------------------------#
33
"""
4-
abstract type Group end
4+
abstract type Group
55
66
Abstract supertype for representing different types of groups. Groups can be used
77
to define Sector subtypes, either via their irreducible representations, or
@@ -11,7 +11,7 @@ are not meant to be instantiated and are defined as abstract types.
1111
abstract type Group end
1212

1313
"""
14-
abstract type AbelianGroup <: Group end
14+
abstract type AbelianGroup <: Group
1515
1616
Abstract supertype for representing different types of Abelian groups.
1717
Abelian groups have both irreps and group elements that have several
@@ -20,7 +20,7 @@ simplified properties, that can be defined in general.
2020
abstract type AbelianGroup <: Group end
2121

2222
"""
23-
abstract type Cyclic{N} <: AbelianGroup end
23+
abstract type Cyclic{N} <: AbelianGroup
2424
2525
Type to represent the cyclic group of order `N`, i.e. the multiplicative
2626
group of roots of unity of order `N`, which is a discrete abelian group.
@@ -30,7 +30,7 @@ and we define the latter as a type alias `const ℤ{N} = Cyclic{N}`.
3030
abstract type Cyclic{N} <: AbelianGroup end
3131

3232
"""
33-
abstract type Dihedral{N} <: Group end
33+
abstract type Dihedral{N} <: Group
3434
3535
Type to represent the dihedral group of order `2N`, which is the symmetry
3636
group of a regular polygon with `N` sides, and is a discrete non-Abelian
@@ -40,23 +40,23 @@ abstract type Dihedral{N} <: Group end
4040

4141

4242
"""
43-
abstract type U₁ <: AbelianGroup end
43+
abstract type U₁ <: AbelianGroup
4444
4545
Type to represent the group ``U(1)`` of complex numbers of unit modulus,
4646
which is a compact Abelian Lie group.
4747
"""
4848
abstract type U₁ <: AbelianGroup end
4949

5050
"""
51-
abstract type SU{N} <: Group end
51+
abstract type SU{N} <: Group
5252
5353
Type to represent the special unitary group ``SU(N)``, which is a
5454
compact non-Abelian Lie group.
5555
"""
5656
abstract type SU{N} <: Group end
5757

5858
"""
59-
abstract type CU₁ <: Group end
59+
abstract type CU₁ <: Group
6060
6161
Type to represent the group of U₁ in combination with charge conjugation,
6262
i.e. the group generated by U₁ and an additional element that acts as
@@ -77,17 +77,17 @@ const SU₂ = SU{2}
7777
type_repr(::Type{ℤ₂}) = "ℤ₂"
7878
type_repr(::Type{ℤ₃}) = "ℤ₃"
7979
type_repr(::Type{ℤ₄}) = "ℤ₄"
80+
type_repr(::Type{ℤ{N}}) where {N} = "ℤ{$N}"
8081
type_repr(::Type{D₃}) = "D₃"
8182
type_repr(::Type{D₄}) = "D₄"
8283
type_repr(::Type{SU₂}) = "SU₂"
8384
type_repr(::Type{U₁}) = "U₁"
8485
type_repr(::Type{CU₁}) = "CU₁"
85-
type_repr(T::Type) = repr(T)
8686

8787
const GroupTuple = Tuple{Vararg{Group}}
8888

8989
"""
90-
abstract type ProductGroup{T <: Tuple{Vararg{Group}}} <: Group end
90+
abstract type ProductGroup{T <: Tuple{Vararg{Group}}} <: Group
9191
9292
Type to represent the direct product of a tuple of groups. This is typically
9393
constructed via the [`×`](@ref) operator.

src/irreps/irreps.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Sectors corresponding to irreducible representations of compact groups
22
#------------------------------------------------------------------------------#
33
"""
4-
abstract type AbstractIrrep{G <: Group} <: Sector end
4+
abstract type AbstractIrrep{G <: Group} <: Sector
55
66
Abstract supertype for sectors which corresponds to irreps (irreducible representations) of
77
a group `G`. As we assume unitary representations, these would be finite groups or compact
@@ -20,7 +20,7 @@ struct IrrepTable end
2020
"""
2121
const Irrep
2222
23-
A constant of a singleton type used as `Irrep[G]` with `G<:Group` a type of group, to
23+
A constant of a singleton type used as `Irrep[G]` with `G <: Group` a type of group, to
2424
construct or obtain a concrete subtype of `AbstractIrrep{G}` that implements the data
2525
structure used to represent irreducible representations of the group `G`.
2626
"""

src/irreps/su2irrep.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
# SU2Irrep: irreps of SU2 are labelled by half integers j
2-
struct SU2IrrepException <: Exception end
3-
function Base.show(io::IO, ::SU2IrrepException)
4-
return print(
5-
io,
6-
"Irreps of (bosonic or fermionic) `SU₂` should be labelled by non-negative half integers, i.e. elements of `Rational{Int}` with denominator 1 or 2"
7-
)
8-
end
9-
101
"""
112
struct SU2Irrep <: AbstractIrrep{SU₂}
123
SU2Irrep(j::Real)

src/product.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
const SectorTuple = Tuple{Vararg{Sector}}
44

55
"""
6-
ProductSector{T<:SectorTuple}
6+
struct ProductSector{T <: SectorTuple}
7+
ProductSector((s₁, s₂, ...))
78
89
Represents the Deligne tensor product of sectors. The type parameter `T` is a tuple of the
910
component sectors. The recommended way to construct a `ProductSector` is using the

0 commit comments

Comments
 (0)