Fix Array and trivialrange for TensorKit-backed ITensors#215
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #215 +/- ##
==========================================
+ Coverage 75.95% 75.99% +0.04%
==========================================
Files 30 30
Lines 1680 1683 +3
==========================================
+ Hits 1276 1279 +3
Misses 404 404
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:
|
4f19332 to
b885ff3
Compare
Fixes two gaps in the TensorKit backend so a `TensorMap`-backed ITensor densifies and gauges correctly. `Array(::AbstractNamedTensor)` now densifies through `convert(Array, ...)` rather than the `Array` constructor, so storage that is not an `AbstractArray`, such as a TensorKit `TensorMap`, goes through its own `convert(Array, ...)` method. It restores the copy the `Array` constructor would have made when `convert` returns the storage unchanged. This is a workaround until TensorKit defines `Array(::AbstractTensorMap)`, at which point it can go back to `Array(unnamed(a))`. The TensorKit extension also overloads `namedunitrange(::ElementarySpace, name)`, not just `named`, which `trivialrange` uses to mint a fresh trivial axis over a native space (needed by the boundary-MPS setup).
b885ff3 to
bb37a7d
Compare
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
Fixes two gaps in the TensorKit backend: densifying a
TensorMap-backed ITensor to a denseArray, and minting a trivial axis over a native TensorKit space.Array(::AbstractNamedTensor)now densifies throughconvert(Array, ...)rather than theArrayconstructor, so storage that is not anAbstractArray, such as a TensorKitTensorMap, goes through its ownconvert(Array, ...)method. It restores the copy theArrayconstructor would have made whenconvertreturns the storage unchanged. This is a workaround until TensorKit definesArray(::AbstractTensorMap), at which point it can go back toArray(unnamed(a)). The TensorKit extension also overloadsnamedunitrange(::ElementarySpace, name), not justnamed, whichtrivialrangeuses to mint the fresh axis (needed by the boundary-MPS setup).