Repository navigation
fix(metrics): compile and run the metrics edge-case tests - #538
EnesKartal wants to merge 5 commits into
Conversation
src/metrics/tests_edge_cases.rs was not declared in src/metrics/mod.rs, so its tests were never built. Declare the module and fix the imports: the regression type is MeanSquareError, and the HCV free functions live in crate::metrics, not in cluster_hcv. homogeneity_score, completeness_score and v_measure_score required T: Number + FloatNumber + RealNumber + Ord. No type meets these bounds, so nothing could call them. They only call ClusterMetrics::hcv_score, which needs T: Number + Ord, so use the same bounds. Closes smartcorelib#535
|
Thanks for this PR. It fixes #535 and stays focused. Declaring the module, fixing the Requested changes / questions
Minor / nits
Follow-up I ignored the lint failure, as you asked. After items 1–5 are addressed and the test jobs are green, this looks good to merge from my side. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #538 +/- ##
===========================================
+ Coverage 43.97% 87.45% +43.48%
===========================================
Files 85 100 +15
Lines 7281 9999 +2718
===========================================
+ Hits 3202 8745 +5543
+ Misses 4079 1254 -2825 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes #535
Checklist
Current behaviour
src/metrics/tests_edge_cases.rsis not declared insrc/metrics/mod.rs, so its 26 tests are never built. If you declare it, it does not compile:MeanSquaredError, but the type isMeanSquareError;homogeneity_score,completeness_scoreandv_measure_scorefrommetrics::cluster_hcv, but these functions are inmetrics;T: Number + FloatNumber + RealNumber + Ord.FloatNumberis only onf32/f64, which are notOrd, so no type can call them.New expected behaviour
mod.rsdeclares#[cfg(test)] mod tests_edge_cases;, and the imports are fixed.homogeneity_score,completeness_scoreandv_measure_scorenow useT: Number + Ord. This is the bound ofClusterMetrics::hcv_score(), which is the only thing they call. The bounds are less strict than before, so no caller breaks, and the functions now work with integer labels (for exampleVec<u32>), as the HCV edge-case tests use them.cargo fmtreformatted the test file (it was never checked before, because it was not part of the crate). I also changed fourx >= 0.0 && x <= 1.0asserts to(0.0..=1.0).contains(&x)so thatcargo clippy --all-targetshas no warnings in the file.Test plan
cargo fmt --checkandcargo clippy --all-features --all-targets -- -Drust-2018-idiomsshow nothing for the changed files.Note: the other
tests_edge_cases.rsfiles (cluster,decomposition,ensemble,linear,naive_bayes,neighbors,svm,tree) are also not declared in theirmod.rs. I did not change them in this PR, to keep it focused on #535.Change logs
Changed
homogeneity_score,completeness_scoreandv_measure_scoreacceptT: Number + Ordlabels.