Skip to content

Add data for TensorKit tensor maps#206

Merged
mtfishman merged 1 commit into
mainfrom
mf/tensorkit-data-leaf
Jul 10, 2026
Merged

Add data for TensorKit tensor maps#206
mtfishman merged 1 commit into
mainfrom
mf/tensorkit-data-leaf

Conversation

@mtfishman

Copy link
Copy Markdown
Member

Summary

Adds a TensorAlgebra.data method for TensorMap and DiagonalTensorMap in the TensorKit extension, so data and datatype resolve for TensorKit-backed tensors. A TensorMap is not an AbstractArray, so it has no Base.parent(::AbstractArray) self-fallback for the generic data recursion to reach, and the recursion had no leaf to bottom out on. The methods route into the flat block storage vector t.data (type storagetype(t)) and keep recursing through data, so any wrapper on that vector is unwrapped to the true leaf. A lazy AdjointTensorMap already defines Base.parent, so the generic recursion unwraps it with no dedicated method, and a general AbstractTensorMap has no single storage vector, so gets no method.

Adds a `TensorAlgebra.data` method for `TensorMap` and `DiagonalTensorMap` in the TensorKit extension, so `data` and `datatype` resolve for TensorKit-backed tensors. A `TensorMap` is not an `AbstractArray`, so it has no `Base.parent(::AbstractArray)` self-fallback for the generic `data` recursion to reach, and the recursion had no leaf to bottom out on. The methods route into the flat block storage vector `t.data` (type `storagetype(t)`) and keep recursing through `data`, so any wrapper on that vector is unwrapped to the true leaf. A lazy `AdjointTensorMap` already defines `Base.parent`, so the generic recursion unwraps it with no dedicated method, and a general `AbstractTensorMap` has no single storage vector, so gets no method.
@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 81.14%. Comparing base (727e6d3) to head (c209e04).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #206      +/-   ##
==========================================
+ Coverage   81.10%   81.14%   +0.04%     
==========================================
  Files          24       24              
  Lines         905      907       +2     
==========================================
+ Hits          734      736       +2     
  Misses        171      171              
Flag Coverage Δ
docs 24.25% <0.00%> (-0.06%) ⬇️

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 enabled auto-merge (squash) July 10, 2026 16:19
@mtfishman
mtfishman merged commit f8749bd into main Jul 10, 2026
24 of 26 checks passed
@mtfishman
mtfishman deleted the mf/tensorkit-data-leaf branch July 10, 2026 16:37
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