Repository navigation
fix(metrics): compile and run the metrics edge-case tests - #538
Open
EnesKartal wants to merge 1 commit into
Open
EnesKartal wants to merge 1 commit into
EnesKartal wants to merge 1 commit 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
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.
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.