Skip to content

Commit

Permalink
Fix tests without libm or std
Browse files Browse the repository at this point in the history
  • Loading branch information
vks committed Dec 17, 2023
1 parent 7413916 commit 58bb5f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tests/integration/covariance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fn simple() {
assert!(cov.sample_variance_y().is_nan());
assert!(cov.population_covariance().is_nan());
assert!(cov.sample_covariance().is_nan());
#[cfg(any(feature = "std", feature = "libm"))]
assert!(cov.pearson().is_nan());

cov.add(1., 5.);
Expand All @@ -22,6 +23,7 @@ fn simple() {
assert!(cov.sample_variance_y().is_nan());
assert_eq!(cov.population_covariance(), 0.);
assert!(cov.sample_covariance().is_nan());
#[cfg(any(feature = "std", feature = "libm"))]
assert!(cov.pearson().is_nan());

cov.add(2., 4.);
Expand All @@ -33,6 +35,7 @@ fn simple() {
assert_eq!(cov.sample_variance_y(), 0.5);
assert_eq!(cov.population_covariance(), -0.25);
assert_eq!(cov.sample_covariance(), -0.5);
#[cfg(any(feature = "std", feature = "libm"))]
assert_eq!(cov.pearson(), -1.);

cov.add(3., 3.);
Expand All @@ -44,6 +47,7 @@ fn simple() {
assert_eq!(cov.sample_variance_y(), 1.);
assert_eq!(cov.population_covariance(), -2./3.);
assert_eq!(cov.sample_covariance(), -1.);
#[cfg(any(feature = "std", feature = "libm"))]
assert_eq!(cov.pearson(), -1.);

cov.add(4., 2.);
Expand All @@ -55,6 +59,7 @@ fn simple() {
assert_eq!(cov.sample_variance_y(), 5./3.);
assert_eq!(cov.population_covariance(), -1.25);
assert_eq!(cov.sample_covariance(), -5./3.);
#[cfg(any(feature = "std", feature = "libm"))]
assert_eq!(cov.pearson(), -1.);

cov.add(5., 1.);
Expand All @@ -66,5 +71,6 @@ fn simple() {
assert_eq!(cov.sample_variance_y(), 2.5);
assert_eq!(cov.population_covariance(), -2.0);
assert_eq!(cov.sample_covariance(), -2.5);
#[cfg(any(feature = "std", feature = "libm"))]
assert_eq!(cov.pearson(), -1.);
}
2 changes: 1 addition & 1 deletion tests/integration/mean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn simple_rayon() {

#[test]
fn numerically_unstable() {
// The naive algorithm fails for this example due to cancelation.
// The naive algorithm fails for this example due to cancellation.
let big = 1e9;
let sample = &[big + 4., big + 7., big + 13., big + 16.];
let a: MeanWithError = sample.iter().collect();
Expand Down

0 comments on commit 58bb5f3

Please sign in to comment.