Skip to content

fusionscalartype, braidingscalartype and dimscalartype#62

Merged
lkdvos merged 8 commits intomainfrom
ld-scalartypes
Jan 31, 2026
Merged

fusionscalartype, braidingscalartype and dimscalartype#62
lkdvos merged 8 commits intomainfrom
ld-scalartypes

Conversation

@lkdvos
Copy link
Member

@lkdvos lkdvos commented Jan 31, 2026

This adds various utility functions to obtain the scalar types of some of the interface functions.

In particular:

  • fusionscalartype <-> scalartype(Fsymbol)
  • braidingscalartype <-> scalartype(Rsymbol)
  • dimscalartype <-> scalartype(dim)

This is useful for keeping tensors with Real scalartypes in planar contexts, and for determining the correct output type of things like rank and cond of anyonic tensors.

I additionally rewrote the implementations to no longer depend on type inference for automatically determining these scalartypes, and rather use :foldable annotations and running actual code.
Overall I think this is slightly cleaner, and while I don't really know what the overall impact is of this, I would argue it is nicer to no longer have to depend on Core.Compiler or Base.promote_op, since that seems to be heavily discouraged anyways.
If this ever shows up as a performance issue, we can always add specializations or re-evaluate.

I also removed some @pure annotations, since we require at least Julia 1.10 anyways.

@codecov
Copy link

codecov bot commented Jan 31, 2026

Codecov Report

❌ Patch coverage is 65.38462% with 27 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/product.jl 18.75% 13 Missing ⚠️
src/precompile.jl 0.00% 5 Missing ⚠️
src/sectors.jl 54.54% 5 Missing ⚠️
src/groups.jl 0.00% 1 Missing ⚠️
src/irreps/irreps.jl 90.90% 1 Missing ⚠️
src/timereversed.jl 75.00% 1 Missing ⚠️
src/trivial.jl 66.66% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/TensorKitSectors.jl 16.66% <ø> (ø)
src/anyons.jl 95.65% <100.00%> (+0.13%) ⬆️
src/fermions.jl 76.74% <100.00%> (+1.13%) ⬆️
src/irreps/a4irrep.jl 100.00% <100.00%> (ø)
src/irreps/cu1irrep.jl 96.47% <100.00%> (+0.05%) ⬆️
src/irreps/dnirrep.jl 98.01% <100.00%> (+0.02%) ⬆️
src/irreps/su2irrep.jl 100.00% <100.00%> (ø)
src/groups.jl 45.71% <0.00%> (ø)
src/irreps/irreps.jl 97.05% <90.90%> (-2.95%) ⬇️
src/timereversed.jl 94.59% <75.00%> (-2.38%) ⬇️
... and 4 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos lkdvos enabled auto-merge (squash) January 31, 2026 15:47

function fusiontensor(a::I, b::I, c::I) where {I <: AbelianIrrep}
return fill(Int(Nsymbol(a, b, c)), (1, 1, 1, 1))
T = sectorscalartype(I)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that it matters, but from the perspective that the Fsymbols can be determined by contracting fusiontensors, I think it makes sense that fusiontensors have fusionscalartype as scalar type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in the cases where fusiontensor exists, it also determines the Rsybmol, so I can also see the sectorscalartype motivation.

In particular, this is the scalar type of [`dim`](@ref).
"""
@assume_effects :foldable dimscalartype(::Type{I}) where {I <: Sector} =
FusionStyle(I) isa UniqueFusion ? Int : typeof(dim(first(allunits(I))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could add:

Suggested change
FusionStyle(I) isa UniqueFusion ? Int : typeof(dim(first(allunits(I))))
(FusionStyle(I) isa UniqueFusion || I isa Irrep) ? Int : typeof(dim(first(allunits(I))))

Copy link
Member

@Jutho Jutho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great; thanks!

@lkdvos lkdvos merged commit b2b536b into main Jan 31, 2026
8 of 9 checks passed
@lkdvos lkdvos deleted the ld-scalartypes branch January 31, 2026 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants