Skip to content

Preserve the codomain/domain split in map construction and aligndims#207

Merged
mtfishman merged 4 commits into
mainfrom
mf/tensormap-construction-permute
Jul 3, 2026
Merged

Preserve the codomain/domain split in map construction and aligndims#207
mtfishman merged 4 commits into
mainfrom
mf/tensormap-construction-permute

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

Map-shaped construction now forwards a codomain/domain split down to the backing storage instead of flattening. randn, rand, and zeros take a codomain and a domain index tuple (randn((i,), (j,))), and the rand_map/randn_map/zeros_map hooks on indices build a backing object partitioned accordingly: a TensorKit TensorMap stores a codomain ← domain map, a dense backend stores flat. Following the similar_map convention the domain is conjugated in the flattened view, so the result is an ordinary tensor over the codomain indices and the duals of the domain indices. This fixes rand_map((i,), (j,)) on TensorMap-backed indices, which previously flattened everything into the codomain.

aligndims gains a map form aligndims(a, codomain, domain) that both repartitions and permutes, and its existing single-tuple form now routes through TensorAlgebra.permutedims so a TensorMap-backed tensor permutes correctly (a TensorMap has no flat permutedims). Both ride the permutedims seam from ITensor/TensorAlgebra.jl#202, so any backend implementing it works with no dedicated method, and a dense backend ignores the split and stores flat.

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.80%. Comparing base (091773d) to head (eb1556c).

Files with missing lines Patch % Lines
src/abstractnamedtensor.jl 85.71% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #207      +/-   ##
==========================================
+ Coverage   74.62%   74.80%   +0.18%     
==========================================
  Files          30       30              
  Lines        1537     1564      +27     
==========================================
+ Hits         1147     1170      +23     
- Misses        390      394       +4     
Flag Coverage Δ
docs 23.35% <3.57%> (-0.43%) ⬇️

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 and others added 4 commits July 2, 2026 19:47
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Build each map constructor from a shared `*_nameddims` helper plus separate
nonempty-codomain and empty-codomain forwarding methods, so an empty codomain
lands in the domain rather than recursing back through the named overload once
the names are stripped.
@mtfishman mtfishman force-pushed the mf/tensormap-construction-permute branch from 36a595b to eb1556c Compare July 2, 2026 23:48
@mtfishman mtfishman changed the title [WIP] Preserve the codomain/domain split in map construction and aligndims Preserve the codomain/domain split in map construction and aligndims Jul 2, 2026
@mtfishman mtfishman marked this pull request as ready for review July 2, 2026 23:49
@mtfishman mtfishman enabled auto-merge (squash) July 2, 2026 23:50
@mtfishman mtfishman merged commit f875628 into main Jul 3, 2026
26 of 28 checks passed
@mtfishman mtfishman deleted the mf/tensormap-construction-permute branch July 3, 2026 00:10
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