Skip to content

test(linalg): add contract tests for flux-independent QR/LQ isometry - #460

Merged
ultimatile merged 1 commit into
mainfrom
test/115-flux-independent-isometry
Jul 11, 2026
Merged

test(linalg): add contract tests for flux-independent QR/LQ isometry#460
ultimatile merged 1 commit into
mainfrom
test/115-flux-independent-isometry

Conversation

@ultimatile

@ultimatile ultimatile commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Add contract tests that name flux-independent isometry as the invariant under test for block-sparse QR/LQ. The property — per-sector orthogonality holds regardless of the tensor's overall flux label — was already implicitly exercised by the identity-flux qr_orthogonality / lq_orthogonality tests, but no test name or docstring called it out. Making it an explicitly named contract, pinned by a non-identity flux fixture, keeps a future reader from conflating the overall flux label with the per-sector isometry condition.

Closes #115

Changes

  • Add qr_orthogonality_holds_for_nonzero_flux and lq_orthogonality_holds_for_nonzero_flux, driven by the existing sample_u1_nonzero_flux() fixture (flux = U1Sector(1)), asserting $Q^\top Q = I$ / $Q Q^\top = I$ per sector.
  • Extract the shared isometry check into assert_orthonormal_columns / assert_orthonormal_rows helpers and route the existing identity-flux orthogonality tests through them, collapsing four near-identical loop bodies into two helpers.

Test plan

  • cargo test -p ariadnetor-linalg: 300 passed, 0 failed (the four orthogonality tests, two new and two refactored, all green).
  • The new tests use a non-identity flux fixture, so they fail if isometry is ever gated on flux rather than computed per sector.

@coderabbitai ignore

Add qr_orthogonality_holds_for_nonzero_flux and
lq_orthogonality_holds_for_nonzero_flux, which pin block-sparse
isometry as a per-sector orthogonality condition independent of the
tensor's overall flux label, using a non-identity flux fixture.

Extract the shared Q^T Q = I / Q Q^T = I checks into
assert_orthonormal_columns / assert_orthonormal_rows helpers and route
the existing identity-flux orthogonality tests through them as well.
@ultimatile
ultimatile requested a review from Copilot July 11, 2026 19:46
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

QR and LQ orthogonality assertions now use shared per-sector isometry helpers, with additional tests covering nonzero-flux tensor fixtures.

Changes

Flux-independent isometry tests

Layer / File(s) Summary
Per-sector isometry helpers
crates/ariadnetor-linalg/src/block_sparse_decomp/tests/mod.rs
Adds shared helpers that verify QR column and LQ row Gram matrices against identity per fused sector.
QR and LQ flux coverage
crates/ariadnetor-linalg/src/block_sparse_decomp/tests/mod.rs
Refactors existing orthogonality tests and adds QR/LQ tests using nonzero-flux fixtures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Poem

I’m a rabbit with matrices bright,
Checking each sector’s shape just right.
QR columns stand tall,
LQ rows answer the call,
Even with flux hopping in sight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: new contract tests for flux-independent QR/LQ isometry in linalg.
Linked Issues check ✅ Passed The changes add nonzero-flux QR/LQ orthogonality tests, reuse the nonzero-flux fixture, and stay within linalg tests as requested.
Out of Scope Changes check ✅ Passed The PR stays scoped to test refactors and new linalg contract tests, with no production or unrelated-module changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/115-flux-independent-isometry

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR strengthens the block-sparse decomposition test suite by making “flux-independent per-sector isometry” an explicit, named contract for QR/LQ factors in ariadnetor-linalg.

Changes:

  • Adds qr_orthogonality_holds_for_nonzero_flux and lq_orthogonality_holds_for_nonzero_flux using the existing sample_u1_nonzero_flux() fixture.
  • Extracts shared orthogonality checks into assert_orthonormal_columns / assert_orthonormal_rows and reuses them from the existing identity-flux orthogonality tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/ariadnetor-linalg/src/block_sparse_decomp/tests/mod.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/ariadnetor-linalg/src/block_sparse_decomp/tests/mod.rs`:
- Around line 369-425: Extract the duplicated Gram-matrix accumulation and
identity assertion logic from assert_orthonormal_columns and
assert_orthonormal_rows into a shared test helper. Parameterize the helper as
needed for the row/column multiplication orientation and dimensions, then have
both existing functions delegate to it while preserving their current tolerances
and behavior.
- Around line 369-425: Remove the redundant PartialEq bound from the generic
signatures of assert_orthonormal_columns and assert_orthonormal_rows. Keep S
constrained only by Sector, leaving their existing calls to
compute_fused_sector_groups and assemble_sector_matrix unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0e710a6c-2f05-4050-a5a5-73f8cbbad874

📥 Commits

Reviewing files that changed from the base of the PR and between f9093ed and 4f3dc25.

📒 Files selected for processing (1)
  • crates/ariadnetor-linalg/src/block_sparse_decomp/tests/mod.rs

Comment thread crates/ariadnetor-linalg/src/block_sparse_decomp/tests/mod.rs
@ultimatile
ultimatile merged commit 58c7e55 into main Jul 11, 2026
2 checks passed
@ultimatile
ultimatile deleted the test/115-flux-independent-isometry branch July 11, 2026 20:10
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.

test(linalg): add contract tests for flux-independent isometry of QR/LQ

2 participants