[WIP] Name-based index-set algebra, whole-tensor index ops, and the id/uuid rename#213
Draft
mtfishman wants to merge 6 commits into
Draft
[WIP] Name-based index-set algebra, whole-tensor index ops, and the id/uuid rename#213mtfishman wants to merge 6 commits into
mtfishman wants to merge 6 commits into
Conversation
…runc ϵ, trivialrange for named ranges Bugfixes and additive index utilities. `ITensor(array, Index-tuple)` now throws with guidance toward `array[i, j]` and `ITensor(array, name.((i, j)))` instead of silently mis-constructing. `replacedimnames` accepts `Index` keys by stripping to the dimname. `svd_trunc` returns the truncation error `ϵ` as a fourth output. And `trivialrange(::NamedUnitRange)` mints a fresh trivial named range on the same backend.
…replaceinds, rank-0 similar/one Whole-tensor index manipulation on `AbstractNamedTensor`. `mapinds(f, t)` relabels every index name-only (leaving the space untouched), with `prime(t)`, `noprime(t)`, and `sim(t)` built on it. `replaceinds` becomes a name-only relabel, a synonym for `replacedimnames`, and `sim(i)` mints a fresh id preserving tags and prime level. `similar(a, ())` and `one(a)` give a rank-0 scalar tensor on `a`'s backend.
Adds `commoninds`, `uniqueinds`, `unioninds`, `noncommoninds`, and `hascommoninds` on `AbstractNamedTensor`, along with the singular `commonind`/`uniqueind` and their non-erroring `trycommonind`/`trynoncommonind` counterparts. Indices are compared by name, so a shared bond matches even when the two tensors carry it as an index on one and its dual on the other.
The function form of `replaceinds`/`mapinds` forwarded straight to `replacedimnames`, so its `f` received a dimension name rather than the index its docstring describes. Apply `f` to each index instead, relabeling name-only through the pair form, so `replaceinds`/`mapinds` are the index-level counterpart of the name-level `replacedimnames`/`mapdimnames`.
…ity constructor Rename the unique-identifier accessor `id` on `IndexName`/`Index` to `uuid` (along with the struct field, the constructor keyword, and the `setuuid` setter), freeing the `id` name for the identity-tensor constructor. Add `id(elt, codomain, domain)`, the from-scratch identity operator over the given codomain and domain indices, a sibling of `one(a, codomain, domain)` that needs only the indices and an element type rather than a prototype tensor. `id` is exported. Breaking: `ITensorBase.id` on an index or index name is now `ITensorBase.uuid`.
`name` already strips an index to its dimension name and passes a bare name through unchanged, so `to_dimname` duplicated it. Call `name` directly when normalizing relabel pairs, which handles either an index or a bare name on either side of the pair.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #213 +/- ##
===========================================
- Coverage 74.40% 23.01% -51.40%
===========================================
Files 30 29 -1
Lines 1567 1590 +23
===========================================
- Hits 1166 366 -800
- Misses 401 1224 +823
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Draft
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A batch of next-generation index and identity utilities for
AbstractNamedTensor, plus one breaking rename. Depends on TensorAlgebra ITensor/TensorAlgebra.jl#205 and is pinned to its branch via[sources]while that is in flight.commoninds,uniqueinds,unioninds,noncommoninds,hascommoninds, the singularcommonind/uniqueind, and the non-erroringtrycommonind/trynoncommonind. Indices match by name, so a shared bond matches even when one tensor carries its dual.prime,noprime, andsimon a tensor relabel every index, built onmapinds/replaceinds. These are the index-level counterpart ofreplacedimnames/mapdimnames, a name-only relabel that changes an index's name and leaves its space untouched.id(elt, codomain, domain): the from-scratch identity operator, a sibling ofone(a, codomain, domain)that needs only the indices and an element type rather than a prototype tensor. Exported.svd_trunctruncation error: the named-tensor wrapper now returns(U, S, Vᴴ, ϵ)to match the matrix-level primitive, so the discarded weight is available directly.replacedimnames, andtrivialrangefor aNamedUnitRange.Breaking: the unique-identifier accessor on an index or index name is renamed from
idtouuid, freeingidfor the identity constructor.TODO
[sources.TensorAlgebra]pin once the required TensorAlgebra version registers.