fix: propagate NaN in Matrix::inf_norm (#85)#92
Conversation
`Matrix::inf_norm()` silently returned 0.0 for matrices containing NaN entries because `NaN > max_row_sum` always evaluates to false, so NaN rows were skipped entirely. This contradicts the expected mathematical behavior that any NaN entry contaminates the norm. - Detect NaN row sums explicitly and short-circuit to `f64::NAN` (marked `cold_path()`). Preferred `f64::maximum` is still unstable behind `float_minimum_maximum` as of Rust 1.95, so the explicit check is used instead. - Document NaN/Inf behavior with a new "Non-finite handling" section and a NaN doctest. - Add regression tests across D=2..=5 via a macro: all-NaN → NaN, single-NaN → NaN, `+∞` entry → `+∞`. Tests: `just ci` — 98 lib, 26 doc, 259 exact-feature, 101 Python, all examples, all linters/validators. Closes #85 Co-Authored-By: Oz <oz-agent@warp.dev>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #92 +/- ##
==========================================
+ Coverage 88.58% 88.65% +0.07%
==========================================
Files 5 5
Lines 482 485 +3
==========================================
+ Hits 427 430 +3
Misses 55 55
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Matrix::inf_norm()silently returned 0.0 for matrices containing NaN entries becauseNaN > max_row_sumalways evaluates to false, so NaN rows were skipped entirely. This contradicts the expected mathematical behavior that any NaN entry contaminates the norm.f64::NAN(markedcold_path()). Preferredf64::maximumis still unstable behindfloat_minimum_maximumas of Rust 1.95, so the explicit check is used instead.+∞entry →+∞.Tests:
just ci— 98 lib, 26 doc, 259 exact-feature, 101 Python, all examples, all linters/validators.Closes #85
Summary by CodeRabbit
Bug Fixes
Documentation
Tests