Skip to content

Fix Array and trivialrange for TensorKit-backed ITensors#215

Merged
mtfishman merged 1 commit into
mainfrom
mf/tensorkit-array-densify
Jul 10, 2026
Merged

Fix Array and trivialrange for TensorKit-backed ITensors#215
mtfishman merged 1 commit into
mainfrom
mf/tensorkit-array-densify

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 10, 2026

Copy link
Copy Markdown
Member

Summary

Fixes two gaps in the TensorKit backend: densifying a TensorMap-backed ITensor to a dense Array, and minting a trivial axis over a native TensorKit space. 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 the fresh axis (needed by the boundary-MPS setup).

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.99%. Comparing base (b32dc08) to head (bb37a7d).

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              
Flag Coverage Δ
docs 26.12% <60.00%> (+0.07%) ⬆️

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 mtfishman force-pushed the mf/tensorkit-array-densify branch 2 times, most recently from 4f19332 to b885ff3 Compare July 10, 2026 16:01
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).
@mtfishman mtfishman force-pushed the mf/tensorkit-array-densify branch from b885ff3 to bb37a7d Compare July 10, 2026 16:13
@mtfishman mtfishman enabled auto-merge (squash) July 10, 2026 16:21
@mtfishman mtfishman merged commit d1c09be into main Jul 10, 2026
18 checks passed
@mtfishman mtfishman deleted the mf/tensorkit-array-densify branch July 10, 2026 16:35
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