Route non-abelian sector spaces to a native TensorKit space#206
Merged
Conversation
`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 Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
to_rangeon a vector ofsector => multiplicitypairs now dispatches on the symmetry of the sector. Abelian sectors (e.g.U1) build a block-sparseGradedOneToexactly as before. Non-abelian sectors (e.g.SU2) have no block-sparse representation, so they now build a native TensorKitGradedSpacevia a newGradedArraysTensorKitExtweak-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 TensorKitGradedSpacedirectly.Adds
test/test_tensorkitext.jl.