You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SliceRandom's shuffle function was reimplemented in 0.9, and it produces a different result when using a deterministic PRNG.
I expect rand's functions to preserve results from one release to the next, for deterministic PRNGs.
Code samples
0.8 version
/// The pseudo-random number generator we use.pubtypeRandom = rand_pcg::Pcg64Mcg;/// Constructs a new Random from a given string seed.pubfnnew_random(seed:&str) -> Random{
rand_seeder::Seeder::from(seed).make_rng()}#[cfg(test)]mod tests {use rand::seq::SliceRandom;usesuper::*;#[test]fntest_random(){letmut rng = new_random("test");letmut nums = [1,2,3,4,5];
nums.shuffle(&mut rng);assert_eq!(nums,[4,3,1,5,2]);}}
0.9 version
/// The pseudo-random number generator we use.pubtypeRandom = rand_pcg::Pcg64Mcg;/// Constructs a new Random from a given string seed.pubfnnew_random(seed:&str) -> Random{
rand_seeder::Seeder::from(seed).into_rng()}#[cfg(test)]mod tests {use rand::seq::SliceRandom;usesuper::*;#[test]fntest_random(){letmut rng = new_random("test");letmut nums = [1,2,3,4,5];
nums.shuffle(&mut rng);// assert_eq!(nums, [4, 3, 1, 5, 2]); -- this fails. The new shuffle produces this other sequence:assert_eq!(nums,[5,1,3,2,4]);}}
The text was updated successfully, but these errors were encountered:
Summary
SliceRandom's shuffle function was reimplemented in 0.9, and it produces a different result when using a deterministic PRNG.
I expect
rand
's functions to preserve results from one release to the next, for deterministic PRNGs.Code samples
0.8 version
0.9 version
The text was updated successfully, but these errors were encountered: