Wrap a TensorKit TensorMap directly as an ITensor#206
Merged
Conversation
Loosen `NamedTensor` and `NamedUnitRange`/`Index` to hold a native TensorKit space and a `TensorMap`, and add `ITensorBaseTensorKitExt` for construction, wrapping under names, and linear-combination broadcasting. Contraction and factorization work through the TensorAlgebra TensorKit backend with no additional code. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #206 +/- ##
==========================================
+ Coverage 74.03% 74.35% +0.31%
==========================================
Files 28 29 +1
Lines 1502 1505 +3
==========================================
+ Hits 1112 1119 +7
+ Misses 390 386 -4
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:
|
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…adcast hooks Routes cold-start `rand`/`randn`/`zeros` over index spaces through TensorAlgebra's map-shaped construction hooks (ITensor/TensorAlgebra.jl#200), which dispatch on the axis type to build a dense `Array`, a block-sparse array, or a `TensorMap`, so ITensorBase no longer carries backend-specific construction. The generic named-tensor machinery (`nameddims`, named `getindex`, and the `copy`/`zero` helper) is loosened to accept any parent a `NamedTensor` can wrap rather than only an `AbstractArray`, and the linear-combination broadcasting now lives in TensorAlgebra, so the TensorKit extension is left holding just the space-backed `Index` adapters. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A comment between a docstring and the definition it documents detaches the docstring, so Documenter reported no docs found for `NamedTensor` and `NamedUnitRange`. Move the field-rationale comments into the struct bodies, onto the fields they explain, leaving each docstring directly above its `struct`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The TensorKit test dependency added here caps VectorInterface at 0.5, so the 0.6 bucket the test compat claimed is unreachable in the test environment. The main package keeps VectorInterface at "0.5, 0.6" since TensorKit is only a weak dependency there. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The TensorKit extension needs TensorKit 0.17, which requires VectorInterface at most 0.5, and no released TensorKit supports VectorInterface 0.6. The 0.6 bucket the compat claimed is therefore unreachable for any consumer using the extension, so drop it to match what the package can resolve to. 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
Lets a native TensorKit space be an
Index, so anITensorwraps a TensorKitTensorMapdirectly as its parent with noAbstractArrayin between.NamedTensorandNamedUnitRange/Indexare loosened to hold aTensorMapand a native space, and the generic named-tensor machinery (nameddims, namedgetindex, and thecopy/zerohelper) is loosened to accept any parent aNamedTensorcan wrap rather than only anAbstractArray, so aTensorMapflows through with no backend-specific path. Cold-start construction (randn/rand/zerosover index spaces) and linear-combination broadcasting (a .+ b,2 .* a) build on the map-shaped construction and broadcast hooks in ITensor/TensorAlgebra.jl#200, which dispatch on the axis type, so the TensorKit extension is left holding just the space-backedIndexadapters. Element-wise broadcasting on a symmetric tensor has no meaning and errors cleanly. Contraction and factorization work through the TensorAlgebra TensorKit backend (ITensor/TensorAlgebra.jl#197) with no additional code.This is the direct route to non-abelian symmetries such as SU(2) through the
ITensorBasetoTensorAlgebratoTensorKitpath.