Skip to content

fix(auc+encoder): review follow-ups from #374, clippy fix, coverage tests, v0.6.0 - #375

Merged
Mec-iS merged 5 commits into
developmentfrom
fix-auc-review-followup
Jul 8, 2026
Merged

fix(auc+encoder): review follow-ups from #374, clippy fix, coverage tests, v0.6.0#375
Mec-iS merged 5 commits into
developmentfrom
fix-auc-review-followup

Conversation

@Mec-iS

@Mec-iS Mec-iS commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #374 (now merged). Applies the remaining review suggestions and an unrelated clippy fix discovered in series_encoder.rs, plus a minor version bump.


src/metrics/auc.rs

  • All-tied-scores edge case test (auc_all_tied_scores): exercises the inner while j < n loop running to n without early exit; asserts AUC = 0.5 (random performance), matching the Wilcoxon expectation.
  • Loop invariant comment: documents that rank[i] for the first element of a tie group is written in the same outer-loop iteration, clarifying the subtle advance of i to j.
  • debug_assert!(label_idx[j] < n): makes the bounds-safety invariant (argsort produces a [0..n) permutation) explicit at runtime in debug builds.
  • Rank-averaging formula comment: notes that (i+1+j)/2 is the average of 1-based ranks [i+1 .. j] inclusive.

src/preprocessing/series_encoder.rs

  • Clippy fix: sort_by(|a, b| a.1.cmp(&b.1))sort_by_key(|a| a.1) (clippy::unnecessary_sort_by, was causing a compile error under -D warnings).
  • 8 new tests covering previously uncovered code paths:
    • num_categories_returns_correct_count
    • get_num_known_and_unknown
    • get_cat_round_trips
    • get_categories_slice_matches_positional_order
    • get_ordinal_unknown_returns_none
    • invert_one_hot_multi_hot_error
    • make_one_hot_direct
    • from_category_map_preserves_order

Cargo.toml

  • Version bump 0.5.00.6.0.

Checklist

Mec-iS added 5 commits July 8, 2026 19:18
- Apply the core fix from PR #374: compare scores in sorted order
  via label_idx to correctly rank-average non-adjacent tied scores.
- Add `auc_all_tied_scores` edge-case test (all predictions equal → AUC 0.5).
- Add comments documenting the rank loop invariant and tie-group logic.
- Add `debug_assert!(label_idx[j] < n)` to make bounds safety explicit.
- Add comment on the rank-averaging formula.
…overage tests

- Fix clippy::unnecessary_sort_by: use sort_by_key(|a| a.1) instead of
  sort_by(|a, b| a.1.cmp(&b.1)) in from_category_map.
- Add tests covering: num_categories(), get_num(), get_cat(),
  get_categories() slice, get_ordinal() for unknown category,
  invert_one_hot() multi-hot error path, and make_one_hot() directly.
@Mec-iS
Mec-iS merged commit 9ed0e63 into development Jul 8, 2026
11 checks passed
@Mec-iS
Mec-iS deleted the fix-auc-review-followup branch July 8, 2026 18:30
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.

1 participant