Add tag verbs, an Index keyword constructor, and factorization bond decoration#214
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #214 +/- ##
==========================================
+ Coverage 74.65% 75.95% +1.30%
==========================================
Files 30 30
Lines 1653 1680 +27
==========================================
+ Hits 1234 1276 +42
+ Misses 419 404 -15
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:
|
…ecoration Rework index tags onto merge-based plural verbs (settags, unsettags, emptytags), add an `Index(space; tags, plev)` keyword constructor and a `uniquename(IndexName; tags, plev)` method, and let factorizations decorate the bonds they mint via a per-bond keyword spec, either a NamedTuple splatted into uniquename or a name-minting callback. settags now merges rather than replaces.
Rename the single-bond and null factorization keyword from `bondname` to `name`, reaching the `name` function through the module (`ITensorBase.name`) in the bodies where the keyword shadows it.
Splat `kwargs...` to the `IndexName` constructor rather than naming `tags`/`plev`, so the type form tracks the constructor's keywords without restating them.
Fold the `Index` keyword constructor into the generic `NamedUnitRange{Name}(space; kwargs...)`, which forwards keywords to `uniquename`, so there is no `IndexName`-specific method. Rename the bond-name canonicalizer `bondnamer` to `to_uniquename_function` and its `NamedTuple` argument to `decoration`, matching the `to_range` naming already in this file. Add a `decoration` fallback returning an empty `NamedTuple` for undecorated names.
Point `[sources.ITensorBase]` in `test/Project.toml` back at `..`. A machine-specific absolute path to a sibling worktree had replaced it, so the test project resolved `ITensorBase` from the wrong checkout.
c6fca9a to
6dd5fb4
Compare
Rename the SVD and eigendecomposition bond-decoration keywords from `rowname`/`colname` to `leftname`/`rightname`, matching legacy ITensor's `lefttags`/`righttags` and the left/right framing used across the tensor-network ecosystem. `leftname` decorates the U-side bond, `rightname` the V-side bond. The single-bond keyword stays `name`.
Document a single `Index(space; tags, plev)` signature and state the keyword defaults (no tags, prime level 0) instead of listing `Index(space)` as a separate signature.
Add the `name`/`leftname`/`rightname` bond-decoration keywords to the Factorizations section of the user interface manual, with a runnable SVD example. The factorizations are wrapped MatrixAlgebraKit methods without ITensorBase docstrings, so the decoration keywords are documented once here rather than on each wrapped function.
Spell the example link tag `"link"` rather than `"Link"` in the tests and the manual.
Word the decoration example as the same SVD with its two bonds tagged, right after the plain `svd_compact` example, and drop the redundant `svd_compact` import (the shared example state already has it).
A comment sitting between the docstring and the definition detached the `settags` docstring, so it fell out of the reference docs and `@ref` links to it could not resolve, failing the docs build. Move the comment after the definition so the docstring attaches.
mtfishman
added a commit
to mtfishman/TensorNetworkQuantumSimulator.jl
that referenced
this pull request
Jul 10, 2026
#3) ## Summary Continues shrinking the `itensors.jl` shim onto the upstream API, now that `ITensorBase` exposes the tag and factorization-decoration verbs (added in ITensor/ITensorBase.jl#214). Builds on #2. - **Name the new bond at the factorization instead of relabeling it after.** The `left_orth` / `right_orth` call sites pass `name = (; tags = ...)`, which mints the bond with the tag directly, so the `commonind` / `settags` / `replaceinds` retag that followed each factorization is gone. The full-update bond takes its tags from `commonind(p, q)`, which errors clearly when there is not exactly one shared index, rather than `trycommonind`. - **Retire the local `settags` shim** for the now-public `ITensorBase.settags`, and mint tagged site and link indices through the `Index(dim; tags = ...)` keyword constructor. - **Take the `loop_correlation` eigenvalues with `eig_vals` directly on the ITensor**, dropping the `matricize` / `adapt` / `Array` densification and the `LinearAlgebra.eigvals` call. It returns the same eigenvalues, and the routine only reads `maximum(abs, λ)` and `sum(abs, λ)`. - **Use the greedy contraction optimizer unconditionally for loop weights.** `weight` picked the optimizer with `hasqns` (exact for graded tensors, greedy otherwise), but `loop_correlation` in the same module already runs greedy on every backend, so drop the branch and the `hasqns` helper it was the only caller of. - **Update the API reference** for the removed `safe_eigen` and the `op` methods that moved into the `Ops` submodule. Verified with the local symmetric smoke across the dense, graded, and TensorKit backends, the package test suite, and a docs build. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Reworks the index tag interface around key-value tags and adds a consistent way to decorate the names that the
Indexconstructor and the factorizations mint.Because tags are key-value pairs, the plural verbs are now merge-based and permissive.
settagsinserts or overwrites the given tags (as one or more pairs, a collection of pairs, or anAbstractDict),unsettagsremoves a collection of keys, andemptytagsclears them. Setting a tag that already exists overwrites it, and removing one that is absent is a no-op. These verbs, together withgettags,gettag,hastag,tags,plev, anddecoration, are nowpublic.settagspreviously replaced the entire tag dictionary and now merges, but it was neither exported norpublic, so this is a non-breaking patch release.Index(2; tags = "i" => "1", plev = 1)mints a fresh index carrying the given tags and prime level, anduniquename(IndexName; tags, plev)does the same at the name level.Factorizations can now decorate the bonds they create. Each new bond takes a keyword,
namefor the single shared bond of theqr/lq/orth/polar/nullfamily, andleftname/rightnamefor the two legs of the central matrix insvdand the eigendecompositions. Each accepts either aNamedTupleof decoration that is splatted intouniquename(leftname = (; tags = "link" => "1")) or a name-minting callback for full control over how the name is built.decoration(i)returns an index's(; tags, plev)for forwarding an existing bond's decoration onto a fresh one. The default leaves bonds bare, so existing calls mint the same undecorated names they do today. The Factorizations section of the user interface manual documents these keywords.Also restores
test/Project.toml's[sources.ITensorBase]path to.., which a machine-specific absolute path had replaced.