Add space for named ranges and accept indices in NamedTensor constructors#218
Merged
Conversation
…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 Report❌ Patch coverage is
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
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:
|
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).
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
Adds
space(i::NamedUnitRange), which returns the underlying range of a named range with the name dropped (equal tounnamedfor aNamedUnitRange).The
NamedTensor/ITensorconstructor now accepts indices (NamedUnitRanges such asIndex) as the dimension names, not only plain names. It uses each index's name and takes the space from the array, soITensor(array, (i, j))works alongside the existingarray[i, j]andITensor(array, name.((i, j)))forms. A single bare index is still rejected, since it is ambiguous as the names collection.Also drops the
Compatdependency, declaring the package's public (non-exported) names with the nativepublickeyword (guarded onVERSIONso the package still loads on Julia 1.10).