Skip to content

Commit

Permalink
Merge #707
Browse files Browse the repository at this point in the history
707: Update rand to 0.7, rand_xorshift to 0.2 r=cuviper a=silwol

There are some method calls which require a mutable reference to the
RNG instance. I chose to create the instance and then immediately create
a reference to it which is then used within this scope. If you know a better
solution, feel free to adjust accordingly.

Co-authored-by: Wolfgang Silbermayr <wolfgang@silbermayr.at>
  • Loading branch information
bors[bot] and silwol committed Dec 19, 2019
2 parents 0aefd61 + 7a396f5 commit ab4d244
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ default-features = false
[dev-dependencies]
docopt = "1"
lazy_static = "1"
rand = "0.6"
rand_xorshift = "0.1"
rand = "0.7"
rand_xorshift = "0.2"
serde = "1"
serde_derive = "1"
doc-comment = "0.3"
109 changes: 100 additions & 9 deletions ci/compat-Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions rayon-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ crossbeam-queue = "0.2"
crossbeam-utils = "0.7"

[dev-dependencies]
rand = "0.6"
rand_xorshift = "0.1"
rand = "0.7"
rand_xorshift = "0.2"
scoped-tls = "1.0"

[target.'cfg(unix)'.dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions rayon-core/src/join/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn seeded_rng() -> XorShiftRng {

#[test]
fn sort() {
let mut rng = seeded_rng();
let rng = seeded_rng();
let mut data: Vec<u32> = rng.sample_iter(&Standard).take(6 * 1024).collect();
let mut sorted_data = data.clone();
sorted_data.sort();
Expand All @@ -48,7 +48,7 @@ fn sort() {

#[test]
fn sort_in_pool() {
let mut rng = seeded_rng();
let rng = seeded_rng();
let mut data: Vec<u32> = rng.sample_iter(&Standard).take(12 * 1024).collect();

let pool = ThreadPoolBuilder::new().build().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions rayon-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ fixedbitset = "0.2.0"
glium = "0.25.1"
lazy_static = "1"
odds = "0.3"
rand = "0.6"
rand_xorshift = "0.1"
rand = "0.7"
rand_xorshift = "0.2"
regex = "1"
serde = "1"
serde_derive = "1"
Expand Down
2 changes: 1 addition & 1 deletion rayon-demo/src/find/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ macro_rules! make_tests {

lazy_static! {
static ref HAYSTACK: Vec<[u32; $n]> = {
let mut rng = crate::seeded_rng();
let rng = crate::seeded_rng();
rng.sample_iter(&Standard)
.map(|x| {
let mut result: [u32; $n] = [0; $n];
Expand Down
2 changes: 1 addition & 1 deletion rayon-demo/src/mergesort/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pub fn is_sorted<T: Send + Ord>(v: &mut [T]) -> bool {
}

fn default_vec(n: usize) -> Vec<u32> {
let mut rng = crate::seeded_rng();
let rng = crate::seeded_rng();
rng.sample_iter(&Standard).take(n).collect()
}

Expand Down
2 changes: 1 addition & 1 deletion rayon-demo/src/quicksort/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn is_sorted<T: Send + Ord>(v: &[T]) -> bool {
}

fn default_vec(n: usize) -> Vec<u32> {
let mut rng = crate::seeded_rng();
let rng = crate::seeded_rng();
rng.sample_iter(&Standard).take(n).collect()
}

Expand Down
5 changes: 3 additions & 2 deletions rayon-demo/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn gen_descending(len: usize) -> Vec<u64> {
}

fn gen_random(len: usize) -> Vec<u64> {
let mut rng = crate::seeded_rng();
let rng = crate::seeded_rng();
rng.sample_iter(&Standard).take(len).collect()
}

Expand Down Expand Up @@ -45,6 +45,7 @@ fn gen_mostly_descending(len: usize) -> Vec<u64> {

fn gen_strings(len: usize) -> Vec<String> {
let mut rng = crate::seeded_rng();
let rng = &mut rng;
let len_dist = Uniform::new(1, 21);
let mut v = vec![];
for _ in 0..len {
Expand All @@ -55,7 +56,7 @@ fn gen_strings(len: usize) -> Vec<String> {
}

fn gen_big_random(len: usize) -> Vec<[u64; 16]> {
let mut rng = crate::seeded_rng();
let rng = crate::seeded_rng();
rng.sample_iter(&Standard)
.map(|x| [x; 16])
.take(len)
Expand Down
8 changes: 5 additions & 3 deletions src/iter/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ fn check_cmp_to_seq() {
#[test]
fn check_cmp_rng_to_seq() {
let mut rng = seeded_rng();
let rng = &mut rng;
let a: Vec<i32> = rng.sample_iter(&Standard).take(1024).collect();
let b: Vec<i32> = rng.sample_iter(&Standard).take(1024).collect();
for i in 0..a.len() {
Expand Down Expand Up @@ -552,6 +553,7 @@ fn check_partial_cmp_to_seq() {
#[test]
fn check_partial_cmp_rng_to_seq() {
let mut rng = seeded_rng();
let rng = &mut rng;
let a: Vec<i32> = rng.sample_iter(&Standard).take(1024).collect();
let b: Vec<i32> = rng.sample_iter(&Standard).take(1024).collect();
for i in 0..a.len() {
Expand Down Expand Up @@ -1522,7 +1524,7 @@ fn par_iter_unindexed_flat_map() {

#[test]
fn min_max() {
let mut rng = seeded_rng();
let rng = seeded_rng();
let a: Vec<i32> = rng.sample_iter(&Standard).take(1024).collect();
for i in 0..=a.len() {
let slice = &a[..i];
Expand All @@ -1533,7 +1535,7 @@ fn min_max() {

#[test]
fn min_max_by() {
let mut rng = seeded_rng();
let rng = seeded_rng();
// Make sure there are duplicate keys, for testing sort stability
let r: Vec<i32> = rng.sample_iter(&Standard).take(512).collect();
let a: Vec<(i32, u16)> = r.iter().chain(&r).cloned().zip(0..).collect();
Expand All @@ -1552,7 +1554,7 @@ fn min_max_by() {

#[test]
fn min_max_by_key() {
let mut rng = seeded_rng();
let rng = seeded_rng();
// Make sure there are duplicate keys, for testing sort stability
let r: Vec<i32> = rng.sample_iter(&Standard).take(512).collect();
let a: Vec<(i32, u16)> = r.iter().chain(&r).cloned().zip(0..).collect();
Expand Down
2 changes: 1 addition & 1 deletion src/slice/quicksort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ mod tests {

#[test]
fn test_heapsort() {
let mut rng = thread_rng();
let rng = thread_rng();

for len in (0..25).chain(500..501) {
for &modulus in &[5, 10, 100] {
Expand Down
2 changes: 1 addition & 1 deletion tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn seeded_rng() -> XorShiftRng {

#[test]
pub fn execute_strings() {
let mut rng = seeded_rng();
let rng = seeded_rng();
let s: String = rng.sample_iter::<char, _>(&Standard).take(1024).collect();

let par_chars: String = s.par_chars().collect();
Expand Down

0 comments on commit ab4d244

Please sign in to comment.