Skip to content

Rework named-type parameters around a single Named scalar#173

Merged
mtfishman merged 1 commit into
mainfrom
mf/named-type-parameters
Jun 20, 2026
Merged

Rework named-type parameters around a single Named scalar#173
mtfishman merged 1 commit into
mainfrom
mf/named-type-parameters

Conversation

@mtfishman

Copy link
Copy Markdown
Member

Summary

Reworks the type parameters of the named array and scalar types so the name leads and every parameter is inferable from the fields, and collapses the named-integer type hierarchy into a single Named scalar.

The named types now read Named{Name, Denamed} (the scalar), AbstractNamedArray{Name, DenamedT, N} <: AbstractArray{Named{Name, DenamedT}, N}, and AbstractNamedUnitRange{Name, DenamedT<:Integer}, with Name leading to match AbstractITensor{DimName} and the element type derived as Named{Name, DenamedT} rather than carried as a separate parameter. The concrete NamedArray, NamedUnitRange, and Index infer all of their parameters from their value and name fields.

A single Named wrapper replaces AbstractNamedInteger, the NamedInteger struct, IndexVal, and NoncontiguousIndex: a named integer is Named{Name, <:Integer}, an index value is Named{IndexName, <:Integer}, and a non-contiguous index is a NamedArray with an IndexName name. NamedInteger stays available as a parametric alias, const NamedInteger{Name, Denamed<:Integer} = Named{Name, Denamed}. Because the wrapper is universal, a NamedArray now works for any element type, where a non-integer NamedArray errored before.

Equality and hashing across named array types are type-agnostic, following Base's array convention ([1, 2, 3] == 1:3 and they hash equally): one generic hash(::AbstractNamedArray) uses a single shared tag rather than the concrete type, so a == b implies hash(a) == hash(b).

Breaking: the type-parameter order and shape change, and the AbstractNamedInteger, NamedInteger struct, IndexVal, and NoncontiguousIndex names are removed.

Reworks the type parameters of the named array and scalar types so the name leads and every parameter is inferable from the fields, and collapses the named-integer type hierarchy into a single `Named` scalar.

The named types now read `Named{Name, Denamed}` (the scalar), `AbstractNamedArray{Name, DenamedT, N} <: AbstractArray{Named{Name, DenamedT}, N}`, and `AbstractNamedUnitRange{Name, DenamedT<:Integer}`, with `Name` leading to match `AbstractITensor{DimName}` and the element type derived as `Named{Name, DenamedT}` rather than carried as a separate parameter. The concrete `NamedArray`, `NamedUnitRange`, and `Index` infer all of their parameters from their `value` and `name` fields.

A single `Named` wrapper replaces `AbstractNamedInteger`, the `NamedInteger` struct, `IndexVal`, and `NoncontiguousIndex`: a named integer is `Named{Name, <:Integer}`, an index value is `Named{IndexName, <:Integer}`, and a non-contiguous index is a `NamedArray` with an `IndexName` name. `NamedInteger` stays available as a parametric alias, `const NamedInteger{Name, Denamed<:Integer} = Named{Name, Denamed}`. Because the wrapper is universal, a `NamedArray` now works for any element type, where a non-integer `NamedArray` errored before.

Equality and hashing across named array types are type-agnostic, following Base's array convention (`[1, 2, 3] == 1:3` and they hash equally): one generic `hash(::AbstractNamedArray)` uses a single shared tag rather than the concrete type, so `a == b` implies `hash(a) == hash(b)`.

Breaking: the type-parameter order and shape change, and the `AbstractNamedInteger`, `NamedInteger` struct, `IndexVal`, and `NoncontiguousIndex` names are removed.
@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 56.32184% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.18%. Comparing base (7bc5ad8) to head (f296031).

Files with missing lines Patch % Lines
src/named.jl 37.14% 22 Missing ⚠️
src/name.jl 67.64% 11 Missing ⚠️
src/abstractnamedarray.jl 33.33% 2 Missing ⚠️
src/abstractitensor.jl 50.00% 1 Missing ⚠️
src/namedarray.jl 50.00% 1 Missing ⚠️
src/namedunitrange.jl 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #173      +/-   ##
==========================================
+ Coverage   73.44%   74.18%   +0.73%     
==========================================
  Files          21       21              
  Lines        1141     1131      -10     
==========================================
+ Hits          838      839       +1     
+ Misses        303      292      -11     
Flag Coverage Δ
docs 22.64% <22.50%> (-0.14%) ⬇️

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) June 20, 2026 02:53
@mtfishman mtfishman merged commit 16972b5 into main Jun 20, 2026
17 of 18 checks passed
@mtfishman mtfishman deleted the mf/named-type-parameters branch June 20, 2026 03:05
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