Fix/median total order - #1
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The changes are well-scoped, preserve documented preconditions (no-NaN “valid” buffers), and add comprehensive tests for the corrected edge cases.
Pull request overview
This PR improves floating-point order-statistics correctness by enforcing a total float ordering (not partial_cmp) and by computing the even-length median midpoint in an overflow-safe way, with added regression tests for edge cases (extremes, infinities, signed zero).
Changes:
- Switch order-statistics comparisons to a total float order via
Float::total_cmp(supporting-0.0vs0.0and infinities deterministically). - Replace
(lower + upper) / 2.0with an overflow-safemidpoint(lower, upper)in the even-length median path. - Add targeted tests covering overflow safety, infinities, and signed-zero semantics; ignore
.worktrees/in Git.
File summaries
| File | Description |
|---|---|
| src/reducers_1d.rs | Use total ordering for float comparisons; introduce overflow-safe midpoint for even median; add extensive regression tests. |
| src/finite.rs | Add Float::total_cmp (default + f32/f64 overrides) to standardize total ordering across kernels. |
| .gitignore | Ignore .worktrees/ directory. |
Review details
- Files reviewed: 2/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
No description provided.