Skip to content

Commit

Permalink
Lower precision of tests where required
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Dec 13, 2020
1 parent 55d9830 commit b802b53
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion rand_distr/src/normal.rs
Expand Up @@ -345,7 +345,8 @@ mod tests {
assert_almost_eq!(lnorm.norm.std_dev, 1.0, 2e-16);

let lnorm = LogNormal::from_mean_cv(e.powf(1.5), (e - 1.0).sqrt()).unwrap();
assert_eq!((lnorm.norm.mean, lnorm.norm.std_dev), (1.0, 1.0));
assert!((lnorm.norm.mean - 1.0).abs() < 1e-15);
assert_eq!(lnorm.norm.std_dev, 1.0);
}
#[test]
fn test_log_normal_invalid_sd() {
Expand Down
6 changes: 3 additions & 3 deletions rand_distr/src/pareto.rs
Expand Up @@ -113,10 +113,10 @@ mod tests {
) {
let mut rng = crate::test::rng(213);
let mut buf = [zero; 4];
for x in &mut buf {
*x = rng.sample(&distr);
for v in expected {
let x = rng.sample(&distr);
assert!((x - v).abs() < 1e-14);
}
assert_eq!(buf, expected);
}

test_samples(Pareto::new(1.0, 1.0).unwrap(), 0f32, &[
Expand Down
2 changes: 1 addition & 1 deletion rand_distr/tests/value_stability.rs
Expand Up @@ -339,6 +339,6 @@ fn cauchy_stability() {
let expected = [15.023088, -5.446413, 3.7092876, 3.112482];
for &a in expected.iter() {
let b = rng.sample(&distr);
assert!((a - b).abs() < 1e-6, "expected: {} = {}", a, b);
assert!((a - b).abs() < 1e-5, "expected: {} = {}", a, b);
}
}

0 comments on commit b802b53

Please sign in to comment.