Skip to content

Make NamedTensor the primary tensor type, ITensor an IndexName alias#193

Merged
mtfishman merged 1 commit into
mainfrom
mf/named-dims-tensor-hierarchy
Jun 29, 2026
Merged

Make NamedTensor the primary tensor type, ITensor an IndexName alias#193
mtfishman merged 1 commit into
mainfrom
mf/named-dims-tensor-hierarchy

Conversation

@mtfishman

@mtfishman mtfishman commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

Make the name-generic types the primary tensor types and turn the ITensor family into IndexName-specialized aliases, mirroring how Index is already NamedUnitRange{IndexName}.

  • AbstractITensor{DimName} becomes AbstractNamedTensor{DimName}, with const AbstractITensor = AbstractNamedTensor{IndexName}.
  • ITensor{DimName} becomes NamedTensor{DimName}, with const ITensor = NamedTensor{IndexName}.
  • ITensorOperator, LazyITensor, and SymbolicITensor are renamed to their NamedTensor* counterparts, each keeping the old name as an IndexName alias. The internal broadcast-style and layout helpers take the NamedTensor* prefix without an alias.

NamedTensor, AbstractNamedTensor, and the ITensor-family aliases are all exported, so existing ITensor / AbstractITensor / Index code and signatures keep working, and show still prints an IndexName tensor as ITensor. IndexName, the dimension-name type carried by Index and behind the ITensor aliases, is now public with a docstring. Source files are renamed to match the new type names.

This is breaking: ITensor is now NamedTensor{IndexName}, so a tensor with non-IndexName dimension names has to be built through NamedTensor or nameddims rather than ITensor.

The ITensorNetworksNext layer will follow the same flip in a later PR, dispatching on AbstractNamedTensor and renaming its network hierarchy to name-generic primaries with IndexName aliases.

@mtfishman mtfishman force-pushed the mf/named-dims-tensor-hierarchy branch from 3f2070b to 55b3b74 Compare June 29, 2026 14:54
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.92163% with 80 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.77%. Comparing base (49caa2b) to head (7c520a5).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/lazyitensors/lazyitensor.jl 55.10% 22 Missing ⚠️
src/abstractnamedtensor.jl 85.03% 19 Missing ⚠️
src/lazyitensors/lazybroadcast.jl 0.00% 9 Missing ⚠️
src/namedtensoroperator.jl 80.00% 8 Missing ⚠️
src/broadcast.jl 70.00% 6 Missing ⚠️
src/lazyitensors/symbolicitensor.jl 80.95% 4 Missing ⚠️
src/namedtensor.jl 76.47% 4 Missing ⚠️
src/lazyitensors/evaluation_order.jl 0.00% 2 Missing ⚠️
src/lazyitensors/itensorbaseextensions.jl 33.33% 2 Missing ⚠️
src/tensoralgebra.jl 88.23% 2 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #193      +/-   ##
==========================================
+ Coverage   73.65%   73.77%   +0.11%     
==========================================
  Files          29       29              
  Lines        1545     1548       +3     
==========================================
+ Hits         1138     1142       +4     
+ Misses        407      406       -1     
Flag Coverage Δ
docs 24.35% <18.41%> (+0.08%) ⬆️

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/named-dims-tensor-hierarchy branch from 55b3b74 to debeefb Compare June 29, 2026 15:23
@mtfishman mtfishman changed the title [WIP] Make NamedDimsTensor the primary tensor type, ITensor an IndexName alias [WIP] Make NamedTensor the primary tensor type, ITensor an IndexName alias Jun 29, 2026
@mtfishman mtfishman force-pushed the mf/named-dims-tensor-hierarchy branch 3 times, most recently from ddf1b83 to 51b53f2 Compare June 29, 2026 18:24
Make the name-generic types the primary tensor types and turn the `ITensor` family into `IndexName`-specialized aliases, mirroring how `Index` is already `NamedUnitRange{IndexName}`.

`AbstractITensor{DimName}` becomes `AbstractNamedTensor{DimName}` and `ITensor{DimName}` becomes `NamedTensor{DimName}`, with `const AbstractITensor = AbstractNamedTensor{IndexName}` and `const ITensor = NamedTensor{IndexName}`. `ITensorOperator`, `LazyITensor`, and `SymbolicITensor` are renamed to their `NamedTensor*` counterparts, each keeping the old name as an `IndexName` alias. The internal broadcast-style and layout helpers take the `NamedTensor*` prefix without an alias, and the source files are renamed to match the new type names.

`NamedTensor`, `AbstractNamedTensor`, and the `ITensor`-family aliases are all exported, so existing `ITensor` / `AbstractITensor` / `Index` code and signatures keep working, and `show` still prints an `IndexName` tensor as `ITensor`. `IndexName`, the dimension-name type carried by `Index` and behind the `ITensor` aliases, is now `public` with a docstring.

This is breaking: `ITensor` is now `NamedTensor{IndexName}`, so a tensor with non-`IndexName` dimension names has to be built through `NamedTensor` or `nameddims` rather than `ITensor`.

The ITensorNetworksNext layer will follow the same flip in a later PR, dispatching on `AbstractNamedTensor` and renaming its network hierarchy to name-generic primaries with `IndexName` aliases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mtfishman mtfishman force-pushed the mf/named-dims-tensor-hierarchy branch from 51b53f2 to 7c520a5 Compare June 29, 2026 20:23
@mtfishman mtfishman changed the title [WIP] Make NamedTensor the primary tensor type, ITensor an IndexName alias Make NamedTensor the primary tensor type, ITensor an IndexName alias Jun 29, 2026
@mtfishman mtfishman marked this pull request as ready for review June 29, 2026 20:24
@mtfishman mtfishman enabled auto-merge (squash) June 29, 2026 20:24
@mtfishman mtfishman merged commit bde999b into main Jun 29, 2026
25 of 28 checks passed
@mtfishman mtfishman deleted the mf/named-dims-tensor-hierarchy branch June 29, 2026 20:39
mtfishman added a commit to ITensor/ITensorNetworksNext.jl that referenced this pull request Jun 30, 2026
## Summary

Update the `ITensorBase` compat to `0.9` (the rename of the primary
tensor types landed in
ITensor/ITensorBase.jl#193). No source changes
are needed: ITensorNetworksNext uses only the `ITensor`-family names,
which 0.9 keeps as aliases of the renamed `NamedTensor` types, and its
`inds` call sites (iteration, `setdiff`, `eltype`) work unchanged now
that `inds` returns a `Vector` instead of a `Tuple`.

This drops support for ITensorBase 0.8, so it is a breaking release.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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