Skip to content

Add space for named ranges and accept indices in NamedTensor constructors#218

Merged
mtfishman merged 2 commits into
mainfrom
mf/named-tensor-space-constructor
Jul 13, 2026
Merged

Add space for named ranges and accept indices in NamedTensor constructors#218
mtfishman merged 2 commits into
mainfrom
mf/named-tensor-space-constructor

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

Adds space(i::NamedUnitRange), which returns the underlying range of a named range with the name dropped (equal to unnamed for a NamedUnitRange).

The NamedTensor/ITensor constructor now accepts indices (NamedUnitRanges such as Index) as the dimension names, not only plain names. It uses each index's name and takes the space from the array, so ITensor(array, (i, j)) works alongside the existing array[i, j] and ITensor(array, name.((i, j))) forms. A single bare index is still rejected, since it is ambiguous as the names collection.

Also drops the Compat dependency, declaring the package's public (non-exported) names with the native public keyword (guarded on VERSION so the package still loads on Julia 1.10).

…tors

Adds `space(i::NamedUnitRange)`, which returns the underlying range of a named range with the name dropped (equal to `unnamed` for a `NamedUnitRange`).

The `NamedTensor`/`ITensor` constructor now accepts indices (`NamedUnitRange`s such as `Index`) as the dimension names, not only plain names. It uses each index's name and takes the space from the array, so `ITensor(array, (i, j))` works alongside the existing `array[i, j]` and `ITensor(array, name.((i, j)))` forms. A single bare index is still rejected, since it is ambiguous as the names collection.
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 76.09%. Comparing base (1066a99) to head (43a2f68).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/namedunitrange.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #218      +/-   ##
==========================================
- Coverage   76.10%   76.09%   -0.02%     
==========================================
  Files          30       30              
  Lines        1691     1694       +3     
==========================================
+ Hits         1287     1289       +2     
- Misses        404      405       +1     
Flag Coverage Δ
docs 25.90% <42.85%> (-0.16%) ⬇️

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.

Declares the package's public (non-exported) names with the native `public` keyword guarded on `VERSION`, dropping the `Compat` dependency. The guard keeps the package loading on Julia 1.10, where `public` is not yet parsed.

Both `NamedTensor` constructors now apply the same bare-index guard and strip names exactly once, instead of the bare method delegating through the parameterized one (which stripped names twice).
@mtfishman mtfishman enabled auto-merge (squash) July 13, 2026 17:36
@mtfishman mtfishman merged commit 267c6b7 into main Jul 13, 2026
18 checks passed
@mtfishman mtfishman deleted the mf/named-tensor-space-constructor branch July 13, 2026 17:52
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