Skip to content

Add flux-canceling randn(sector, inds) constructors#230

Open
mtfishman wants to merge 4 commits into
mainfrom
mf/flux-canceling-constructor
Open

Add flux-canceling randn(sector, inds) constructors#230
mtfishman wants to merge 4 commits into
mainfrom
mf/flux-canceling-constructor

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 24, 2026

Copy link
Copy Markdown
Member

Summary

Adds flux-canceling constructors randn/rand/zeros/ones/fill(c, codomain[, domain]) at the Index level, so an ITensor over graded (block-sparse) indices can be built carrying a nonzero total charge c. They mint a fresh auxiliary Index carrying c and forward to the map-shaped split constructor, appending the aux to the domain dangling last so the physical indices fuse to c. The sector may be a bare TensorKitSectors.Sector or a SectorRange. These live in a new ITensorBaseGradedArraysExt, since ITensorBase does not depend on the sector types.

Filling out the constructor surface these build on, this also adds the split (codomain, domain) forms of ones and fill to ITensorBase core (alongside the existing zeros), and lets randn/rand take a leading rng without an explicit element type (matching Base.randn(rng, dims...)) across the flat, split, and flux forms.

Builds on ITensor/GradedArrays.jl#220 and ITensor/TensorAlgebra.jl#216.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.35294% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.02%. Comparing base (e4396ff) to head (8e7603e).

Files with missing lines Patch % Lines
ext/ITensorBaseGradedArraysExt.jl 71.42% 4 Missing ⚠️
src/abstractnamedtensor.jl 90.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #230      +/-   ##
==========================================
+ Coverage   77.88%   78.02%   +0.14%     
==========================================
  Files          29       30       +1     
  Lines        1709     1734      +25     
==========================================
+ Hits         1331     1353      +22     
- Misses        378      381       +3     
Flag Coverage Δ
docs 26.85% <2.94%> (-0.41%) ⬇️

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.

Extend the map-shaped `(codomain, domain)` constructors to `ones` and `fill` alongside `zeros`, routing them through `TensorAlgebra.ones_map`/`fill_map`, and cover them in the `Index`-level flux-canceling forms in `ITensorBaseGradedArraysExt`.
Add the `randn(rng, axes...)`/`rand(rng, axes...)` signatures (default element type) that `Base` supports, covering the flat, split `(codomain, domain)`, and flux `(sector, ...)` forms, so the ITensorBase rng-first surface matches `Base` and the GradedArrays backend.
@mtfishman mtfishman changed the title [WIP] Add flux-canceling randn(sector, inds) constructors Add flux-canceling randn(sector, inds) constructors Jul 24, 2026
@mtfishman
mtfishman marked this pull request as ready for review July 24, 2026 20:50
@mtfishman
mtfishman enabled auto-merge (squash) July 24, 2026 20:50
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