[codex] remove ordered-float from core rank transform#99
Conversation
There was a problem hiding this comment.
Code Review
This pull request removes the ordered-float dependency and replaces its usage in rank_transform with a custom, deterministic tie-breaking comparator cmp_finite_f32_then_index that uses coordinate indices to break ties. It also adds unit tests to verify correct tie-breaking behavior. The reviewer suggested replacing .expect(...) with .unwrap_or(...) in the comparator to eliminate a panic branch, allowing the compiler to better optimize the hot sorting path.
Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
25bf5a0 to
ba3e117
Compare
Review Summary by QodoRemove ordered-float dependency, use internal comparator
WalkthroughsDescription• Replace OrderedFloat dependency with internal finite-f32 comparator • Implement cmp_finite_f32_then_index for deterministic tie-breaking by index • Remove ordered-float from dependencies and deny allowlist • Add test coverage for duplicate values and signed-zero tie behavior Diagramflowchart LR
A["rank_transform functions"] -->|"replace OrderedFloat"| B["cmp_finite_f32_then_index"]
B -->|"sort by value then index"| C["deterministic rank output"]
D["Cargo.toml"] -->|"remove dependency"| E["ordered-float removed"]
F["Tests"] -->|"add coverage"| G["duplicate values & signed zeros"]
File Changes1. src/rank.rs
|
Code Review by Qodo
1.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Removes the ordered-float dependency from the core crate by introducing an internal cmp_finite_f32_then_index comparator used by rank_transform and rank_transform_into. The new comparator preserves prior tie-break semantics (ascending original index) and relies on the existing assert_all_finite contract upstream. Lockfiles, manifest, and deny.toml comment are updated; two new unit tests cover duplicate-value and signed-zero tie cases.
Changes:
- Add
cmp_finite_f32_then_indexhelper insrc/util.rsand switchrank_transform/rank_transform_intotosort_unstable_bywith the new comparator. - Drop
ordered-floatfromCargo.toml,Cargo.lock, andfuzz/Cargo.lock; update the license comment indeny.toml. - Add
duplicate_values_tie_by_original_indexandsigned_zeroes_tie_by_original_indexunit tests insrc/rank.rs.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/util.rs | Adds internal finite-f32 comparator with index tiebreak. |
| src/rank.rs | Replaces OrderedFloat sort key with new comparator; doc tweak and added tie tests. |
| Cargo.toml | Removes ordered-float dependency. |
| Cargo.lock | Drops ordered-float entry from core crate deps. |
| fuzz/Cargo.lock | Drops ordered-float, num-traits, autocfg entries (no longer needed). |
| deny.toml | Updates license-summary comment to drop removed crates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
|
Bot review disposition for the remaining top-level finding:
Validation after the docs fix:
|
Summary
OrderedFloatsort keys in the rank transform with an internal finite-f32comparator that preserves ascending-index tie breaks.ordered-floatfrom the core crate manifest and lockfiles, including the excluded fuzz lockfile.Credit
ordered-floatfrom the core dependency tree.Impact
No public API change. Valid finite inputs keep the same rank output semantics, including
-0.0/+0.0comparing equal and tying by original coordinate index. Non-finite inputs still fail through the existingassert_all_finitecontract before sorting.Validation
cargo fmt --all --checkcargo clippy --all-targets --all-features -- -D warningscargo test --all-featurescargo tree -p ordvec --edges normal