Skip to content

Keep the trailing auxiliary axis in a dense project - #217

Merged
mtfishman merged 1 commit into
mainfrom
mf/project-preserve-trailing-aux
Jul 29, 2026
Merged

Keep the trailing auxiliary axis in a dense project#217
mtfishman merged 1 commit into
mainfrom
mf/project-preserve-trailing-aux

Conversation

@mtfishman

Copy link
Copy Markdown
Member

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 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.

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
mtfishman enabled auto-merge (squash) July 29, 2026 00:55
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.79%. Comparing base (d54e11f) to head (63551ff).

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     
Flag Coverage Δ
docs 21.83% <0.00%> (-0.07%) ⬇️

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.

@mtfishman
mtfishman merged commit 33f459a into main Jul 29, 2026
20 of 21 checks passed
@mtfishman
mtfishman deleted the mf/project-preserve-trailing-aux branch July 29, 2026 01:15
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