From df79467245063ea03e3d8a31d9a729bf9fd7c0cd Mon Sep 17 00:00:00 2001 From: TD-Sky Date: Wed, 26 Feb 2025 00:01:56 +0800 Subject: [PATCH] bump rand to 0.9.0 --- Cargo.toml | 2 +- src/sort.rs | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7582329..d89a80f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ ndarray = "0.16.0" noisy_float = "0.2.0" num-integer = "0.1" num-traits = "0.2" -rand = "0.8.3" +rand = "0.9.0" itertools = { version = "0.13", default-features = false } indexmap = "2.4" diff --git a/src/sort.rs b/src/sort.rs index f43a95b..b1c2473 100644 --- a/src/sort.rs +++ b/src/sort.rs @@ -1,8 +1,7 @@ use indexmap::IndexMap; use ndarray::prelude::*; use ndarray::{Data, DataMut, Slice}; -use rand::prelude::*; -use rand::thread_rng; +use rand::{prelude::*, rng}; /// Methods for sorting and partitioning 1-D arrays. pub trait Sort1dExt @@ -115,8 +114,8 @@ where if n == 1 { self[0].clone() } else { - let mut rng = thread_rng(); - let pivot_index = rng.gen_range(0..n); + let mut rng = rng(); + let pivot_index = rng.random_range(0..n); let partition_index = self.partition_mut(pivot_index); if i < partition_index { self.slice_axis_mut(Axis(0), Slice::from(..partition_index)) @@ -250,8 +249,8 @@ fn _get_many_from_sorted_mut_unchecked( } // We pick a random pivot index: the corresponding element is the pivot value - let mut rng = thread_rng(); - let pivot_index = rng.gen_range(0..n); + let mut rng = rng(); + let pivot_index = rng.random_range(0..n); // We partition the array with respect to the pivot value. // The pivot value moves to `array_partition_index`.