Skip to content
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CategoryData"
uuid = "8fccf25a-f50e-468c-8fba-3cb130506274"
authors = ["Lukas Devos", "Jacob Bridgeman"]
version = "0.3.5"
version = "0.3.6"

[deps]
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Expand All @@ -11,6 +11,7 @@ SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
SparseArrayKit = "a9a3c162-d163-4c15-8926-b8794fbefed2"
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
TensorKitSectors = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"

[compat]
Downloads = "1"
Expand All @@ -19,8 +20,8 @@ Pkg = "1"
SHA = "0.7, 1"
SparseArrayKit = "0.4"
Tar = "1"
TensorKitSectors = "0.3.9"
TensorOperations = "5"
TensorKitSectors = "0.3"
TestExtras = "0.3"
julia = "1.10"

Expand All @@ -29,7 +30,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"

[targets]
test = ["Test", "TestExtras", "LinearAlgebra", "Random", "TensorOperations"]
test = ["Test", "TestExtras", "LinearAlgebra", "Random"]
2 changes: 1 addition & 1 deletion src/CategoryData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using Tar, Inflate, SHA
using TensorKitSectors
using TensorKitSectors: SectorValues
using TensorKitSectors: SimpleFusion, GenericFusion, Anyonic, NoBraiding

using TensorOperations: @tensor
using SparseArrayKit

export FusionRing, FusionCategory, BraidedCategory
Expand Down
61 changes: 61 additions & 0 deletions src/artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,53 @@ end
end
end

# remove the view calls
function TensorKitSectors.Fsymbol_from_fusiontensor(
a::Object{I}, b::Object{I}, c::Object{I},
d::Object{I}, e::Object{I}, f::Object{I}
) where {I <: FusionCategory}
T = fusionscalartype(Object{I})
Nabe, Necd, Nbcd, Nafd = Nsymbol(a, b, e), Nsymbol(e, c, d), Nsymbol(b, c, f), Nsymbol(a, f, d)
if iszero(Nabe * Necd * Nbcd * Nafd)
return TensorKitSectors.FusionStyle(Object{I}) isa TensorKitSectors.MultiplicityFreeFusion ? zero(T) : zeros(T, Nabe, Necd, Nbcd, Nafd)
else
A = fusiontensor(a, b, e)
B = fusiontensor(e, c, d)[:, :, 1, :]
C = fusiontensor(b, c, f)
D = fusiontensor(a, f, d)[:, :, 1, :]

@tensor F[-1, -2, -3, -4] := conj(D[1, 5, -4]) * conj(C[2, 4, 5, -3]) * A[1, 2, 3, -1] * B[3, 4, -2]
return TensorKitSectors.FusionStyle(Object{I}) isa TensorKitSectors.MultiplicityFreeFusion ? only(F) : F
end
end
function TensorKitSectors.Asymbol_from_fusiontensor(a::Object{F}, b::Object{F}, c::Object{F}) where {F <: FusionCategory}
Nabc = Nsymbol(a, b, c)
T = fusionscalartype(Object{F})
if Nabc == 0
return TensorKitSectors.FusionStyle(Object{F}) isa TensorKitSectors.MultiplicityFreeFusion ? zero(T) : zeros(T, 0, 0)
else
C1 = fusiontensor(a, b, c)[:, 1, :, :]
C2 = fusiontensor(dual(a), c, b)[:, :, 1, :]
Za = sqrtdim(a) * fusiontensor(a, dual(a), leftunit(a))[:, :, 1, 1]
@tensor A[-1, -2] := sqrtdim(b) / sqrtdim(c) * conj(Za[1, 2]) * C1[1, 3, -1] * C2[2, 3, -2]
return TensorKitSectors.FusionStyle(Object{F}) isa TensorKitSectors.MultiplicityFreeFusion ? only(A) : A
end
end
function TensorKitSectors.Bsymbol_from_fusiontensor(a::Object{F}, b::Object{F}, c::Object{F}) where {F <: FusionCategory}
Nabc = Nsymbol(a, b, c)
T = fusionscalartype(Object{F})
if Nabc == 0
return TensorKitSectors.FusionStyle(Object{F}) isa TensorKitSectors.MultiplicityFreeFusion ? zero(T) : zeros(T, 0, 0)
else
C1 = fusiontensor(a, b, c)[1, :, :, :]
C2 = fusiontensor(c, dual(b), a)[:, :, 1, :]
Zb = sqrtdim(b) * fusiontensor(b, dual(b), leftunit(b))[:, :, 1, 1]
@tensor B[-1, -2] := sqrtdim(a) / sqrtdim(c) * conj(Zb[1, 2]) * C1[1, 3, -1] * C2[3, 2, -2]
return TensorKitSectors.FusionStyle(Object{F}) isa TensorKitSectors.MultiplicityFreeFusion ? only(B) : B
end
end


# Rsymbols
# --------

Expand Down Expand Up @@ -292,6 +339,20 @@ end
end
end

# remove view calls
function TensorKitSectors.Rsymbol_from_fusiontensor(a::Object{F}, b::Object{F}, c::Object{F}) where {F <: BraidedCategory}
Nabc = Nsymbol(a, b, c)
T = braidingscalartype(Object{F})
if Nabc == 0
return TensorKitSectors.FusionStyle(Object{F}) isa TensorKitSectors.MultiplicityFreeFusion ? zero(T) : zeros(T, 0, 0)
else
A = fusiontensor(a, b, c)[:, :, 1, :]
B = fusiontensor(b, a, c)[:, :, 1, :]
@tensor R[-1 -2] := conj(B[1 2 -2]) * A[2 1 -1]
return TensorKitSectors.FusionStyle(Object{F}) isa TensorKitSectors.MultiplicityFreeFusion ? only(R) : R
end
end

# fusiontensors
# -------------

Expand Down
2 changes: 1 addition & 1 deletion src/objects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function TensorKitSectors.dual(a::Object{F}) where {F}
return a
else
return Object{F}(
findfirst(x -> Nsymbol(a, x, one(a)) == 1, collect(values(typeof(a))))
findfirst(x -> Nsymbol(a, x, unit(a)) == 1, collect(values(typeof(a))))
)
end
end
Expand Down
39 changes: 0 additions & 39 deletions test/braidedcategories.jl

This file was deleted.

75 changes: 0 additions & 75 deletions test/fusioncategories.jl

This file was deleted.

35 changes: 15 additions & 20 deletions test/fusionrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@
Istr = TensorKitSectors.type_repr(I)

@testset "Sector $Istr: Basic properties" begin
s = (randsector(I), randsector(I), randsector(I))
@test eval(Meta.parse(sprint(show, I))) == I
@test eval(Meta.parse(TensorKitSectors.type_repr(I))) == I
@test eval(Meta.parse(sprint(show, s[1]))) == s[1]
@test @constinferred(hash(s[1])) == hash(deepcopy(s[1]))
@test @constinferred(one(s[1])) == @constinferred(one(I))
@constinferred dual(s[1])
# @constinferred dim(s[1])
# @constinferred frobeniusschur(s[1])
@constinferred Nsymbol(s...)
# BraidingStyle(I) isa TensorKitSectors.NoBraiding || @constinferred Rsymbol(s...)
# @constinferred Bsymbol(s...)
# @constinferred Fsymbol(s..., s...)
it = @constinferred s[1] ⊗ s[2]
@constinferred ⊗(s..., s...)
s = rand(collect(values(I)), 3)
@test Base.eval(Main, Meta.parse(sprint(show, I))) == I
@test Base.eval(Main, Meta.parse(TensorKitSectors.type_repr(I))) == I
@test Base.eval(Main, Meta.parse(sprint(show, s[1]))) == s[1]
@test @testinferred(hash(s[1])) == hash(deepcopy(s[1]))
@test @testinferred(unit(s[1])) == @testinferred(unit(I))
@testinferred dual(s[1])
@testinferred Nsymbol(s...)
@testinferred(s[1] ⊗ s[2])
@testinferred(⊗(s..., s...))
end

@testset "Sector $Istr: Value iterator" begin
@test eltype(values(I)) == I
sprev = one(I)
sprev = unit(I)
for (i, s) in enumerate(values(I))
@test !isless(s, sprev) # confirm compatibility with sort order
if Base.IteratorSize(values(I)) == Base.IsInfinite() && I <: ProductSector
Expand All @@ -35,12 +30,12 @@
sprev = s
i >= 10 && break
end
@test one(I) == first(values(I))
@test unit(I) == first(values(I))
if Base.IteratorSize(values(I)) == Base.IsInfinite() && I <: ProductSector
@test_throws ArgumentError TensorKitSectors.findindex(values(I), one(I))
@test_throws ArgumentError TensorKitSectors.findindex(values(I), unit(I))
elseif hasmethod(Base.getindex, Tuple{typeof(values(I)), Int})
@test (@constinferred TensorKitSectors.findindex(values(I), one(I))) == 1
for s in smallset(I)
@test (@constinferred TensorKitSectors.findindex(values(I), unit(I))) == 1
for s in values(I)
@test (@constinferred values(I)[TensorKitSectors.findindex(values(I), s)]) == s
end
end
Expand Down
56 changes: 28 additions & 28 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
using CategoryData
using Test, TestExtras, Random
using Test, TestExtras
using Random
using TensorKitSectors
using TensorKitSectors: fusiontensor, triangle_equation, pentagon_equation, hexagon_equation
using Base.Iterators: product
using LinearAlgebra: LinearAlgebra
using TensorOperations: @tensor

Random.seed!(1234)

smallset(::Type{I}) where {I <: Object} = values(I)
function randsector(::Type{I}) where {I <: Object}
s = collect(smallset(I))
a = rand(s)
while a == one(a) # don't use trivial label
a = rand(s)
testsuite_path = joinpath(
dirname(dirname(pathof(TensorKitSectors))), # TensorKitSectors root
"test", "testsuite.jl"
)
include(testsuite_path)
using .SectorTestSuite: randsector

SectorTestSuite.smallset(::Type{I}) where {I <: Object} = collect(values(I))

# sector tests
@testset "Fusion rings" begin
include("fusionrings.jl") # custom test selection
end

@testset "Fusion categories" begin
for sector in CategoryData.list_fusioncategories()
SectorTestSuite.test_sector(Object{sector})
end
return a
end

function hasfusiontensor(I::Type{<:Object})
try
fusiontensor(one(I), one(I), one(I))
return true
catch e
if e isa MethodError
return false
else
rethrow(e)
end
@testset "Braided categories" begin
for sector in CategoryData.list_braidedcategories()
SectorTestSuite.test_sector(Object{sector})
end
end

include("fusionrings.jl")
include("fusioncategories.jl")
include("braidedcategories.jl")
SectorTestSuite.test_sector(Object{RepA4} ⊠ Object{Fib})

# printing tests
object_name_list = [Fib, Ising, H1, H2, H3] # these have unit alias :I
Expand All @@ -43,8 +43,8 @@ object_name_list = [Fib, Ising, H1, H2, H3] # these have unit alias :I
Istr = TensorKitSectors.type_repr(I)

@testset "Pretty printing of Sector $Istr" begin
@test @constinferred(convert(I, :I)) == one(I)
@test eval(Meta.parse(sprint(show, I(:I)))) == one(I) == I(:I) == I(1)
@test @constinferred(convert(I, :I)) == unit(I)
@test eval(Meta.parse(sprint(show, I(:I)))) == unit(I) == I(:I) == I(1)

s = randsector(I)
@test eval(Meta.parse(sprint(show, s))) == I(s.id) == s
Expand All @@ -53,8 +53,8 @@ end

@testset "Pretty printing of Sector Object{ZVecS3}" begin
I = Object{ZVecS3}
@test @constinferred(convert(I, :A)) == one(I)
@test eval(Meta.parse(sprint(show, I(:A)))) == one(I) == I(:A) == I(1)
@test @constinferred(convert(I, :A)) == unit(I)
@test eval(Meta.parse(sprint(show, I(:A)))) == unit(I) == I(:A) == I(1)

s = randsector(I)
@test eval(Meta.parse(sprint(show, s))) == I(s.id) == s
Expand All @@ -67,7 +67,7 @@ end
@objectnames testcat2 = UFC{5, 1, 2, 4, 0} α β γ δ ε
@objectnames testcat3 = PMFC{6, 1, 0, 4, 0, 7} a b c d e f

@test Object{testcat}(:A) == one(Object{testcat})
@test Object{testcat}(:A) == unit(Object{testcat})
@test Object{testcat2}(:β) == Object{testcat2}(2)
@test Object{testcat3}(:c) == Object{testcat3}(3)
end
Expand Down
Loading