Skip to content

feat(exact): report determinant scale overflow precisely#141

Merged
acgetchell merged 2 commits into
mainfrom
feat/139-exact-det-scale-overflow
Jun 4, 2026
Merged

feat(exact): report determinant scale overflow precisely#141
acgetchell merged 2 commits into
mainfrom
feat/139-exact-det-scale-overflow

Conversation

@acgetchell

@acgetchell acgetchell commented Jun 4, 2026

Copy link
Copy Markdown
Owner
  • Add a typed LaError::DeterminantScaleOverflow path for exact determinant scale exponent failures
  • Convert det_exact_f64 directly from the shared Bareiss integer/exponent pair while preserving Overflow for finite-f64 conversion failures
  • Reuse vector finiteness scanning across raw and proof-bearing constructors
  • Harden docs version sync checks for reordered inline-table dependency snippets and pruned Markdown traversal

Closes #139

Summary by CodeRabbit

  • New Features

    • Added explicit error for determinant scaling overflow and improved exact→f64 determinant conversion.
  • Bug Fixes

    • More reliable detection of stale dependency snippets in documentation checks (handles inline-table forms and reordered keys).
  • Documentation

    • Expanded Matrix guidance and added an [Unreleased] changelog section with version-sync notes.
  • Tests

    • Broadened tests for exact determinant behavior with mixed-scale values and added a test for reordered inline-table keys.

- Add a typed LaError::DeterminantScaleOverflow path for exact determinant scale exponent failures
- Convert det_exact_f64 directly from the shared Bareiss integer/exponent pair while preserving Overflow for finite-f64 conversion failures
- Reuse vector finiteness scanning across raw and proof-bearing constructors
- Harden docs version sync checks for reordered inline-table dependency snippets and pruned Markdown traversal

Closes #139
@acgetchell acgetchell self-assigned this Jun 4, 2026
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bf9807a0-b934-468b-bb31-c3f994fc5839

📥 Commits

Reviewing files that changed from the base of the PR and between 928f62b and 532093a.

📒 Files selected for processing (1)
  • src/exact.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/exact.rs

📝 Walkthrough

Walkthrough

Refactors exact determinant→f64 conversion to use a direct bigint+exponent helper and adds DeterminantScaleOverflow; centralizes vector finiteness scanning; removes redundant LU/LDLT tolerance tests; and improves docs-version-sync script, tests, and CHANGELOG entries.

Changes

Exact Determinant Scaling and Error Handling

Layer / File(s) Summary
DeterminantScaleOverflow error variant definition
src/lib.rs
LaError::DeterminantScaleOverflow enum variant with dim and min_exponent, a const fn constructor, Display formatting, and a unit test for the message.
Exact determinant f64 conversion and error handling
src/exact.rs, src/lib.rs
Adds bigint_exp_to_finite_f64 to convert (BigInt, exp) → f64 without materializing BigRational, introduces determinant_scale_exp for checked D*e_min scaling returning DeterminantScaleOverflow, updates bareiss_det_int_finite and FiniteMatrix::det_exact_f64, and revises determinant docs to include the new error.
Mixed-scale determinant property tests
tests/proptest_exact.rs
Adds mixed_scale_finite_f64 strategy and gen_mixed_scale_diagonal_exact_det_proptests! (D=2..=5) verifying det_exact, det_sign_exact, and det_exact_f64 against BigRational expectations and overflow/non-finite cases.

Vector Finiteness Centralization

Layer / File(s) Summary
Shared finiteness scanning helper and refactoring
src/vector.rs
Adds internal first_non_finite_entry_in that scans entries and returns the first non-finite index; FiniteVector::new and Vector::try_new now use this helper for consistent LaError::non_finite_at behavior.
Tolerance test cleanup
src/ldlt.rs, src/lu.rs
Removes redundant invalid_tolerance_rejected tests from both factorization test modules.

Documentation Sync Tooling and Changelog

Layer / File(s) Summary
Docs version sync script improvements
scripts/check_docs_version_sync.py
Adds os.walk-based markdown discovery with SKIP_DIRS filtering and broadens the dependency-snippet regex to match quoted and inline-table forms with arbitrary key ordering.
Docs version sync test coverage
scripts/tests/test_check_docs_version_sync.py
Adds from __future__ import annotations, Path type hints for tmp_path, updates test signatures, and adds a test for reordered inline-table keys producing a stale-snippet mismatch.
Changelog and module documentation updates
CHANGELOG.md, src/matrix.rs
Adds an [Unreleased] section and compare link, updates a [0.4.2] bullet, and expands Matrix module docs describing fixed-size/stack allocation guidance and links to other crates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

documentation, enhancement, rust, testing, api

"🐰
I hopped through integers, exponents, and docs so neat,
No BigRational bloomed — a slimmer f64 to meet.
One helper finds the first non-finite spot,
Tests and changelogs tidy, regexes catch the lot.
A little rabbit clap for code that's neat and fleet."

🚥 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 PR title "feat(exact): report determinant scale overflow precisely" directly reflects the main objective of adding typed DeterminantScaleOverflow error handling for exact determinant calculations, matching the changeset focus.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from #139: removes redundant tolerance tests in LU/LDLT, consolidates vector finiteness scanning via first_non_finite_entry_in helper, preserves public APIs, and adds DeterminantScaleOverflow error variant.
Out of Scope Changes check ✅ Passed All changes are scoped to #139 objectives: determinant scale overflow handling, vector finiteness consolidation, test removal/addition, and documentation improvements. Documentation updates to CHANGELOG, matrix module, and docs version sync are supporting changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feat/139-exact-det-scale-overflow

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

@acgetchell acgetchell enabled auto-merge June 4, 2026 16:32
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.36364% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.61%. Comparing base (90a4200) to head (532093a).

Files with missing lines Patch % Lines
src/exact.rs 95.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #141      +/-   ##
==========================================
+ Coverage   99.47%   99.61%   +0.14%     
==========================================
  Files           5        5              
  Lines        2838     2846       +8     
==========================================
+ Hits         2823     2835      +12     
+ Misses         15       11       -4     
Flag Coverage Δ
unittests 99.61% <96.36%> (+0.14%) ⬆️

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.

@acgetchell acgetchell disabled auto-merge June 4, 2026 16:37
- Extract determinant scale exponent calculation into a private helper
- Assert typed DeterminantScaleOverflow errors for dimension conversion and exponent product overflow
@acgetchell acgetchell enabled auto-merge June 4, 2026 16:44
@acgetchell acgetchell merged commit 4b792c4 into main Jun 4, 2026
18 checks passed
@acgetchell acgetchell deleted the feat/139-exact-det-scale-overflow branch June 4, 2026 16:49
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.

Simplify redundant tolerance tests and vector finiteness scanning

1 participant