Skip to content

Rename the named-dimension interface and make construction strict - #264

Merged
mtfishman merged 7 commits into
mainfrom
mf/interface-renames
Sep 27, 2026
Merged

mtfishman merged 7 commits into
mainfrom
mf/interface-renames

Conversation

@mtfishman

@mtfishman mtfishman commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Brings the named-dimension interface onto plainer names, makes construction strict, and restricts broadcasting to linear expressions.

What changes

  • replaceinds -> rename, now exported, absorbing replacedimnames, mapinds and mapdimnames
  • dimnames -> names, which is ITensorBase's own function with Base.names forwarding to it, so a new tensor type has one place to overload. dimnametype -> nametype
  • aligndims -> align, aligneddims -> aligned
  • named, nameddims, namedunitrange, namedarray and namedoneto -> the explicit Named, NamedTensor, NamedUnitRange, NamedArray and NamedOneTo
  • A dimension given as an index now asserts its space on construction, and a mismatch throws instead of being ignored
  • matricize returns a plain matrix, and unmatricize takes named axes and returns a named tensor
  • Broadcasting is linear-only. A sum of tensors, a scalar multiple and conj fold as before, and anything else throws rather than falling back to a generic element-wise broadcast over the unnamed operands. map broadcasts, so it goes the same way
  • New NamedTensor(array, codomain_inds, domain_inds) for a map-shaped tensor, taking the domain inds codomain-facing and rejecting a bipartition the array itself contradicts

Brings the named-dimension interface onto plainer names, with `dimnames` becoming `Base.names` and the lowercase constructors giving way to the CamelCase ones.

Breaking: a dimension given as an index now asserts its space on construction, and `matricize` returns a plain matrix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.12121% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.91%. Comparing base (9acfd80) to head (ef7fdd7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/tensoralgebra.jl 86.30% 20 Missing ⚠️
src/abstractnamedtensor.jl 87.36% 12 Missing ⚠️
src/abstractnamedarray.jl 45.45% 6 Missing ⚠️
src/named.jl 50.00% 3 Missing ⚠️
src/namedunitrange.jl 78.57% 3 Missing ⚠️
src/lazyitensors/lazyitensor.jl 50.00% 2 Missing ⚠️
src/namedtensoroperator.jl 85.71% 2 Missing ⚠️
src/lazyitensors/evaluation_order.jl 50.00% 1 Missing ⚠️
src/lazyitensors/symbolicitensor.jl 88.88% 1 Missing ⚠️
src/namedtensor.jl 98.24% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #264      +/-   ##
==========================================
+ Coverage   77.83%   77.91%   +0.07%     
==========================================
  Files          30       30              
  Lines        1796     1807      +11     
==========================================
+ Hits         1398     1408      +10     
- Misses        398      399       +1     
Flag Coverage Δ
docs 25.79% <39.32%> (+0.50%) ⬆️

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 6 commits September 26, 2026 13:43
A new tensor type overloads `names`, and `Base.names` forwards to it, so both spellings work while there is one place to implement.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The internal helpers and the `NamedDimsCartesianIndex` types still read in the `nameddims` vocabulary the public surface moved off, so they take the `namedtensor` stem matching `NamedTensor`. `rename` also moves to `export`, since it replaces `replaceinds` and `mapinds`, which were both exported.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`NamedCartesianIndex` subtypes `Base.AbstractCartesianIndex` and is not a tensor, so it takes the `Named` plus Base-type form used by `NamedInteger`, `NamedUnitRange` and the `NamedIndexCartesian` style beside it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`NamedTensor(array, codomain_inds, domain_inds)` now rejects a bipartition the
array contradicts, which `TensorAlgebra.has_bipartition` makes
possible to check. Raises the floors to TensorAlgebra 0.21.1 and GradedArrays 0.16.5.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A broadcast that is not a sum, a scalar multiple or `conj` now throws rather
than falling back to a generic element-wise broadcast over the unnamed
operands. `map` broadcasts, so it goes the same way.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`check_input` is now the whole argument contract for building a `NamedTensor`.
The dimension count and the distinctness of names had been checked in the inner
constructor instead, so the contract read in two places.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mtfishman
mtfishman enabled auto-merge (squash) September 27, 2026 17:33
@mtfishman
mtfishman merged commit 7ba9f4d into main Sep 27, 2026
18 of 20 checks passed
@mtfishman
mtfishman deleted the mf/interface-renames branch September 27, 2026 17:34
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