Skip to content

Commit

Permalink
fix: compilation failed in MSRV
Browse files Browse the repository at this point in the history
  • Loading branch information
JamboChen committed Oct 9, 2024
1 parent 78f6d0d commit 1148574
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions rand_distr/tests/cdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,19 +426,20 @@ fn hypergeometric() {

#[test]
fn poisson() {
fn cdf(k: i64, lambda: f64) -> f64 {
fn cdf(k: i64, lambda: f32) -> f64 {
if k < 0 || lambda <= 0.0 {
return 0.0;
}

1.0 - lambda.inc_gamma(k as f64 + 1.0)
1.0 - lambda.inc_gamma(k as f32 + 1.0) as f64
}

let parameters = [0.5, 1.0, 7.5, 32.0, 100.0];
let parameters = [0.5_f32, 1.0, 7.5, 32.0, 100.0, 1.844e19];

for (seed, lambda) in parameters.into_iter().enumerate() {
let dist = rand_distr::Poisson::new(lambda).unwrap();
test_discrete::<u64>(seed as u64, dist, |k| cdf(k, lambda));
// `f64` will unable to compile in MSRV 1.61.0
test_discrete(seed as u64, dist, |k| cdf(k, lambda));
}
}

Expand Down

0 comments on commit 1148574

Please sign in to comment.