Skip to content

Commit 0aca902

Browse files
authored
SmallRng uses wrong seed_from_u64 implementation (#1203)
* Forward inner seed_from_u64 implmentation for SmallRng * increase tolerance of sparkline tests
1 parent 21131af commit 0aca902

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

rand_distr/tests/pdf.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ fn normal() {
8989
.fold(core::f64::NEG_INFINITY, |a, &b| a.max(b))
9090
);
9191
for (&d, &e) in diff.iter().zip(expected_error.iter()) {
92-
// Difference larger than 3 standard deviations or cutoff
93-
let tol = (3. * e).max(1e-4);
92+
// Difference larger than 4 standard deviations or cutoff
93+
let tol = (4. * e).max(1e-4);
9494
assert!(d <= tol, "Difference = {} * tol", d / tol);
9595
}
9696
}
@@ -172,8 +172,8 @@ fn skew_normal() {
172172
.fold(core::f64::NEG_INFINITY, |a, &b| a.max(b))
173173
);
174174
for (&d, &e) in diff.iter().zip(expected_error.iter()) {
175-
// Difference larger than 3 standard deviations or cutoff
176-
let tol = (3. * e).max(1e-4);
175+
// Difference larger than 4 standard deviations or cutoff
176+
let tol = (4. * e).max(1e-4);
177177
assert!(d <= tol, "Difference = {} * tol", d / tol);
178178
}
179179
}

src/rngs/small.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,9 @@ impl SeedableRng for SmallRng {
114114
fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error> {
115115
Rng::from_rng(rng).map(SmallRng)
116116
}
117+
118+
#[inline(always)]
119+
fn seed_from_u64(state: u64) -> Self {
120+
SmallRng(Rng::seed_from_u64(state))
121+
}
117122
}

0 commit comments

Comments
 (0)