Skip to content

Fix sectorscalartype fallback definition for UniqueFusion() sector types #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TensorKitSectors"
uuid = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"
authors = ["Lukas Devos", "Jutho Haegeman"]
version = "0.1.2"
version = "0.1.3"

[deps]
HalfIntegers = "f0d1745a-41c9-11e9-1dd9-e5d34d218721"
Expand Down
17 changes: 12 additions & 5 deletions src/sectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,21 @@
Return the scalar type of the topological data (Fsymbol, Rsymbol) of the sector `I`.
"""
function sectorscalartype(::Type{I}) where {I<:Sector}
if BraidingStyle(I) isa NoBraiding
return eltype(Core.Compiler.return_type(Fsymbol, NTuple{6,I}))
if BraidingStyle(I) === NoBraiding()
return _Fscalartype(I)

Check warning on line 109 in src/sectors.jl

View check run for this annotation

Codecov / codecov/patch

src/sectors.jl#L109

Added line #L109 was not covered by tests
else
Feltype = eltype(Core.Compiler.return_type(Fsymbol, NTuple{6,I}))
Reltype = eltype(Core.Compiler.return_type(Rsymbol, NTuple{3,I}))
return Base.promote_op(*, Feltype, Reltype)
return Base.promote_op(*, _Fscalartype(I), _Rscalartype(I))
end
end
function _Fscalartype(::Type{I}) where {I<:Sector}
Ftype = Core.Compiler.return_type(Fsymbol, NTuple{6,I})
return FusionStyle(I) === UniqueFusion() ? Ftype : eltype(Ftype)
end
function _Rscalartype(::Type{I}) where {I<:Sector}
BraidingStyle(I) === NoBraiding() && throw(ArgumentError("No braiding for sector $I"))
Rtype = Core.Compiler.return_type(Rsymbol, NTuple{3,I})
return FusionStyle(I) === UniqueFusion() ? Rtype : eltype(Rtype)
end

"""
isreal(::Type{<:Sector}) -> Bool
Expand Down
11 changes: 8 additions & 3 deletions test/sectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ Istr = TKS.type_repr(I)
@constinferred dim(s[1])
@constinferred frobeniusschur(s[1])
@constinferred Nsymbol(s...)
@constinferred Rsymbol(s...)
@constinferred Bsymbol(s...)
@constinferred Fsymbol(s..., s...)
R = @constinferred Rsymbol(s...)
B = @constinferred Bsymbol(s...)
F = @constinferred Fsymbol(s..., s...)
if FusionStyle(I) === SimpleFusion()
@test typeof(R * F) <: @constinferred sectorscalartype(I)
else
@test Base.promote_op(*, eltype(R), eltype(F)) <: @constinferred sectorscalartype(I)
end
it = @constinferred s[1] ⊗ s[2]
@constinferred ⊗(s..., s...)
end
Expand Down
Loading