Keep the trailing auxiliary axis in a dense project - #217
Merged
Conversation
Fixes `project(raw, codomain_axes, domain_axes)` on a dense backend dropping a trailing dim-1 auxiliary axis (the flux-canceling leg a codomain/domain split introduces, which callers pass as `reshape(a, (size(a)..., 1))`). The generic `allocate_project` allocated a destination shaped only by the given axes, so `projectto!` reshaped `raw` down to that smaller shape and the aux leg vanished, returning a rank-2 array for a rank-3 input. The generic `allocate_project` now handles a trailing surplus axis the way the graded and `TensorMap` backends already do: it appends that axis, taken from `raw` itself, to the domain, so the result's rank matches `raw`'s. More than one trailing surplus axis throws. This lets the same `project` / `project_aux` / `project_pair` construction build states and charge-shifting operators on dense sites without a caller-side workaround to re-add the dropped axis.
mtfishman
enabled auto-merge (squash)
July 29, 2026 00:55
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #217 +/- ##
==========================================
- Coverage 81.93% 81.79% -0.15%
==========================================
Files 28 28
Lines 1002 1005 +3
==========================================
+ Hits 821 822 +1
- Misses 181 183 +2
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:
|
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
Fixes
project(raw, codomain_axes, domain_axes)on a dense backend dropping a trailing dim-1 auxiliary axis (the flux-canceling leg a codomain/domain split introduces, which callers pass asreshape(a, (size(a)..., 1))). The genericallocate_projectallocated a destination shaped only by the given axes, soprojectto!reshapedrawdown to that smaller shape and the aux leg vanished, returning a rank-2 array for a rank-3 input.The generic
allocate_projectnow handles a trailing surplus axis the way the graded andTensorMapbackends already do: it appends that axis, taken fromrawitself, to the domain, so the result's rank matchesraw's. More than one trailing surplus axis throws. This lets the sameproject/project_aux/project_pairconstruction build states and charge-shifting operators on dense sites without a caller-side workaround to re-add the dropped axis.