diff --git a/docs/make.jl b/docs/make.jl index 6765daa3..ac7cb3e3 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -11,6 +11,10 @@ mathengine = MathJax3( ) ) ) +DocMeta.setdocmeta!( + TensorKitSectors, :DocTestSetup, :(using TensorKitSectors); recursive = true +) + makedocs(; sitename = "TensorKitSectors.jl", format = Documenter.HTML(; diff --git a/docs/src/sectors/abelian/trivial.md b/docs/src/sectors/abelian/trivial.md index bff8dd7e..f9634060 100644 --- a/docs/src/sectors/abelian/trivial.md +++ b/docs/src/sectors/abelian/trivial.md @@ -1,3 +1,9 @@ +```@meta +DocTestSetup = quote + using TensorKitSectors +end +``` + # Trivial Sector: `Trivial` `Trivial` is the trivial sector for ordinary vector spaces. @@ -11,9 +17,8 @@ Trivial There is only one label: -```julia -using TensorKitSectors - +```jldoctest +julia> Trivial() Trivial() ``` diff --git a/docs/src/sectors/abelian/u1.md b/docs/src/sectors/abelian/u1.md index 88ebf3e2..799c1233 100644 --- a/docs/src/sectors/abelian/u1.md +++ b/docs/src/sectors/abelian/u1.md @@ -1,3 +1,9 @@ +```@meta +DocTestSetup = quote + using TensorKitSectors +end +``` + # ``U(1)`` Representations: `U1Irrep` `U1Irrep` represents irreducible representations of the compact abelian group ``U(1)`` as a `Sector`. @@ -36,11 +42,12 @@ Since this is a representation category, the braiding style is `Bosonic()` and a `values(U1Irrep)` is infinite. The iterator starts at zero and alternates positive and negative charges: -```julia -using TensorKitSectors +```jldoctest +julia> values(U1Irrep)[6] +Irrep[U₁](3/2) -values(U1Irrep)[6] # output: Irrep[U₁](3/2) -values(U1Irrep)[7] # output: Irrep[U₁](-3/2) +julia> values(U1Irrep)[7] +Irrep[U₁](-3/2) ``` ## References diff --git a/docs/src/sectors/abelian/zn.md b/docs/src/sectors/abelian/zn.md index a9a28506..24e0497a 100644 --- a/docs/src/sectors/abelian/zn.md +++ b/docs/src/sectors/abelian/zn.md @@ -1,3 +1,9 @@ +```@meta +DocTestSetup = quote + using TensorKitSectors +end +``` + # Cyclic Group Representations: `ZNIrrep` `ZNIrrep{N}` and `LargeZNIrrep{N}` represent irreducible representations of the cyclic group ``ℤ_N``. @@ -38,11 +44,12 @@ The braiding style is `Bosonic()`. `values(ZNIrrep{N})` iterates charges in increasing order from `0` to `N - 1`. -```julia -using TensorKitSectors +```jldoctest +julia> values(ZNIrrep{5})[4] +Irrep[ℤ{5}](3) -values(ZNIrrep{5})[4] # output is Irrep[ℤ{5}](3) -values(ZNIrrep{34})[34] # output is Irrep[ℤ{34}](33) +julia> values(ZNIrrep{34})[34] +Irrep[ℤ{34}](33) ``` ## References diff --git a/docs/src/sectors/composite/named.md b/docs/src/sectors/composite/named.md index 8f399e14..9d6742bd 100644 --- a/docs/src/sectors/composite/named.md +++ b/docs/src/sectors/composite/named.md @@ -1,3 +1,9 @@ +```@meta +DocTestSetup = quote + using TensorKitSectors +end +``` + # Named Sectors: `NamedSector` `NamedSector` represents the same Deligne tensor product as [`ProductSector`](@ref), but stores its component sectors in a *named* tuple so that they can be accessed by name rather than by position. @@ -12,15 +18,21 @@ NamedSector A named sector is constructed with keyword arguments to `⊠`/`NamedSector`, or from a type built with the [`@NamedSector`](@ref) macro: -```julia -using TensorKitSectors +```jldoctest +julia> s = ⊠(; charge = U1Irrep(1), spin = SU2Irrep(1//2)) +NamedSector(; charge=Irrep[U₁](1), spin=Irrep[SU₂](1/2)) + +julia> s.charge +Irrep[U₁](1) + +julia> s.spin +Irrep[SU₂](1/2) -s = ⊠(; charge = U1Irrep(1), spin = SU2Irrep(1//2)) # (charge=1, spin=1/2) -s.charge # 1 -s.spin # 1/2 +julia> I = @NamedSector{charge::U1Irrep, spin::SU2Irrep} +NamedSector{@NamedTuple{charge::U1Irrep, spin::SU2Irrep}} -I = @NamedSector{charge::U1Irrep, spin::SU2Irrep} -I(U1Irrep(1), SU2Irrep(1//2)) # same as above +julia> I(U1Irrep(1), SU2Irrep(1//2)) +NamedSector(; charge=Irrep[U₁](1), spin=Irrep[SU₂](1/2)) ``` diff --git a/docs/src/sectors/composite/product.md b/docs/src/sectors/composite/product.md index 42545bc8..a3415387 100644 --- a/docs/src/sectors/composite/product.md +++ b/docs/src/sectors/composite/product.md @@ -1,3 +1,9 @@ +```@meta +DocTestSetup = quote + using TensorKitSectors +end +``` + # Product Sectors: `ProductSector` `ProductSector` represents the Deligne tensor product of sector categories. @@ -15,20 +21,22 @@ A product sector stores its component sectors in a tuple. The recommended constructor is the Deligne product operator `⊠` (typed as `\boxtimes`). The more verbose alias `deligneproduct` is also available: -```julia -using TensorKitSectors +```jldoctest +julia> a = Z2Irrep(1) ⊠ FibonacciAnyon(:τ) +(Irrep[ℤ₂](1) ⊠ FibonacciAnyon(:τ)) -a = Z2Irrep(1) ⊠ FibonacciAnyon(:τ) # (Irrep[ℤ₂](1) ⊠ FibonacciAnyon(:τ)) -deligneproduct(Z2Irrep(1), FibonacciAnyon(:τ)) # same as above +julia> deligneproduct(Z2Irrep(1), FibonacciAnyon(:τ)) # same as above +(Irrep[ℤ₂](1) ⊠ FibonacciAnyon(:τ)) ``` The same operator works on sector types: -```julia -using TensorKitSectors +```jldoctest +julia> I = Z2Irrep ⊠ FibonacciAnyon +ProductSector{Tuple{Z2Irrep, FibonacciAnyon}} -I = Z2Irrep ⊠ FibonacciAnyon -a = I(1, :τ) +julia> a = I(1, :τ) +(Irrep[ℤ₂](1) ⊠ FibonacciAnyon(:τ)) ``` Products are flattened, and `Trivial` factors are removed: diff --git a/docs/src/sectors/composite/timereversed.md b/docs/src/sectors/composite/timereversed.md index e670bf38..dbb66009 100644 --- a/docs/src/sectors/composite/timereversed.md +++ b/docs/src/sectors/composite/timereversed.md @@ -1,3 +1,9 @@ +```@meta +DocTestSetup = quote + using TensorKitSectors +end +``` + # Time-Reversed Sectors: `TimeReversed` `TimeReversed{I}` represents the time-reversed, or conjugate-braided, version of a sector type `I`. @@ -13,12 +19,15 @@ timereversed Construct a wrapped sector with `TimeReversed(a)` or `TimeReversed{I}(a)`. The helper `timereversed(a)` avoids unnecessary wrappers for symmetric braiding categories and unwraps an already time-reversed sector: -```julia -using TensorKitSectors +```jldoctest +julia> a = IsingAnyon(:σ) +IsingAnyon(:σ) + +julia> timereversed(a) +TimeReversed{IsingAnyon}(:σ) -a = IsingAnyon(:σ) -timereversed(a) # TimeReversed{IsingAnyon}(:σ) -timereversed(timereversed(a)) # IsingAnyon(:σ) +julia> timereversed(timereversed(a)) +IsingAnyon(:σ) ``` `TimeReversed` is not defined for sectors with `NoBraiding()`. diff --git a/src/named.jl b/src/named.jl index 8d0eb130..927a896e 100644 --- a/src/named.jl +++ b/src/named.jl @@ -11,15 +11,15 @@ Similar to [`ProductSector`](@ref), but components are accessible by name via `s # Examples -```julia +```jldoctest julia> s = NamedSector(; charge=U1Irrep(1), spin=SU2Irrep(1//2)) -(charge=1, spin=1/2) +NamedSector(; charge=Irrep[U₁](1), spin=Irrep[SU₂](1/2)) julia> s.charge -1 +Irrep[U₁](1) julia> s.spin -1/2 +Irrep[SU₂](1/2) ``` !!! warning @@ -182,12 +182,12 @@ Convenience macro for constructing a `NamedSector` type with named components, analogous to `@NamedTuple`. # Examples -```julia +```jldoctest julia> @NamedSector{charge::U1Irrep, spin::SU2Irrep} NamedSector{@NamedTuple{charge::U1Irrep, spin::SU2Irrep}} julia> (@NamedSector{charge::U1Irrep, spin::SU2Irrep})(U1Irrep(1), SU2Irrep(1//2)) -(charge=1, spin=1/2) +NamedSector(; charge=Irrep[U₁](1), spin=Irrep[SU₂](1/2)) ``` """ macro NamedSector(ex)