Skip to content

Route non-abelian sector spaces to a native TensorKit space#206

Merged
mtfishman merged 6 commits into
mainfrom
mf/tensorkit-space-to_range
Jul 2, 2026
Merged

Route non-abelian sector spaces to a native TensorKit space#206
mtfishman merged 6 commits into
mainfrom
mf/tensorkit-space-to_range

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

to_range on a vector of sector => multiplicity pairs now dispatches on the symmetry of the sector. Abelian sectors (e.g. U1) build a block-sparse GradedOneTo exactly as before. Non-abelian sectors (e.g. SU2) have no block-sparse representation, so they now build a native TensorKit GradedSpace via a new GradedArraysTensorKitExt weak-dependency extension.

The sector's arrow rides inside the space: a shared dual flag across the pairs produces a dual space, and mixed arrows error. Without TensorKit loaded, the non-abelian path throws a clear error pointing at using TensorKit, while the abelian path is unchanged.

This lets a non-abelian sector list flow into the TensorKit-backed tensor path: to_range([SU2(0) => 1, SU2(1) => 2]) produces the same native space as constructing the TensorKit GradedSpace directly.

Adds test/test_tensorkitext.jl.

`to_range` on `sector => multiplicity` pairs now dispatches on symmetry.
Abelian sectors keep the block-sparse `GradedOneTo` backend. Non-abelian
sectors build a native TensorKit `GradedSpace` via a new
`GradedArraysTensorKitExt`, with the arrow riding inside the space.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.21053% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.83%. Comparing base (afea845) to head (4e86a3c).

Files with missing lines Patch % Lines
src/gradedoneto.jl 83.33% 2 Missing ⚠️
src/sectorrange.jl 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #206      +/-   ##
==========================================
- Coverage   81.86%   81.83%   -0.04%     
==========================================
  Files          23       24       +1     
  Lines        1864     1877      +13     
==========================================
+ Hits         1526     1536      +10     
- Misses        338      341       +3     
Flag Coverage Δ
docs 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

mtfishman and others added 5 commits July 2, 2026 11:41
Fold the `_sectorstyle`/`_to_range` helpers into two `to_range` methods that
dispatch on `SymmetryStyle` inline, and drop the `isempty` fallback that
wrongly routed empty non-abelian pairs to `gradedrange`. Add an idempotent
`SectorRange(::SectorRange)` constructor so the extension normalizes keys
without its own helper.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…hods

Define `SymmetryStyle` directly on `TensorKitSectors.Sector` via the fusion
rule and have `SectorRange` delegate to it, so both sector-pair `to_range`
methods share one body that dispatches on `SymmetryStyle` inline.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The outer method normalizes keys to `SectorRange` and reads off the shared
arrow, then hands the sector labels and that flag to `_to_tensorkit_space`,
which builds the `GradedSpace` entirely in TensorKit terms.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The `SectorRange`-keyed `to_tensorkit_space` method now lives in GradedArrays proper: it strips the sector labels, checks that the pairs share one arrow, builds the non-dual space, and flips it with `dual` when the arrow is dual. Only the label-keyed TensorKit `GradedSpace` builder and a `dual` bridge on TensorKit spaces stay in the extension, so the routing logic is expressed once in GradedArrays terms and the extension holds just the TensorKit specifics.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`Vect[S]` accepts the `sector => multiplicity` pairs as a single iterable, so pass the vector directly rather than splatting it. Splatting a long sector list builds a large tuple and dispatches through varargs, which the iterable constructor avoids.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mtfishman mtfishman merged commit f045de6 into main Jul 2, 2026
18 checks passed
@mtfishman mtfishman deleted the mf/tensorkit-space-to_range branch July 2, 2026 16:59
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.

1 participant