From 790979a26de103f8cc15f4271781aecad004707d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 28 Apr 2021 20:00:24 +0000 Subject: [PATCH 1/3] build(deps): update rand requirement from 0.7.3 to 0.8.3 Updates the requirements on [rand](https://github.com/rust-random/rand) to permit the latest version. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/0.7.3...0.8.3) Signed-off-by: dependabot-preview[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ef99307..c2b6825 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ ndarray = { version = "0.14", optional = true } nalgebra = { version = "0.23.0", optional = true } num-traits = "0.2.12" num = "0.3.0" -rand = "0.7.3" +rand = "0.8.3" rand_distr = "0.3.0" serde = { version = "1.0.115", features = ["derive"], optional = true } From 703dc9688b1061959911b637e7f6f2c8ec89192b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 28 Apr 2021 20:00:23 +0000 Subject: [PATCH 2/3] build(deps): update rand_distr requirement from 0.3.0 to 0.4.0 Updates the requirements on [rand_distr](https://github.com/rust-random/rand) to permit the latest version. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/rand_distr-0.3.0...rand_distr-0.4.0) --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c2b6825..61e922c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ nalgebra = { version = "0.23.0", optional = true } num-traits = "0.2.12" num = "0.3.0" rand = "0.8.3" -rand_distr = "0.3.0" +rand_distr = "0.4.0" serde = { version = "1.0.115", features = ["derive"], optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] From c295a0d1bb1a8aeb18aa14f400c97ffac0a75bbf Mon Sep 17 00:00:00 2001 From: Luis Moreno Date: Wed, 28 Apr 2021 16:28:43 -0400 Subject: [PATCH 3/3] fix: fix code to be compatible with rand 0.8, following the recommendations of https://rust-random.github.io/book/update-0.8.html and https://docs.rs/getrandom/0.2.2/getrandom/#webassembly-support --- Cargo.toml | 2 +- src/cluster/kmeans.rs | 2 +- src/ensemble/random_forest_classifier.rs | 2 +- src/ensemble/random_forest_regressor.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 61e922c..f1e805c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ rand_distr = "0.4.0" serde = { version = "1.0.115", features = ["derive"], optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] -rand = { version = "0.7.3", features = ["wasm-bindgen"] } +getrandom = { version = "0.2", features = ["js"] } [dev-dependencies] criterion = "0.3" diff --git a/src/cluster/kmeans.rs b/src/cluster/kmeans.rs index 69f40db..fd43a14 100644 --- a/src/cluster/kmeans.rs +++ b/src/cluster/kmeans.rs @@ -245,7 +245,7 @@ impl KMeans { let mut rng = rand::thread_rng(); let (n, m) = data.shape(); let mut y = vec![0; n]; - let mut centroid = data.get_row_as_vec(rng.gen_range(0, n)); + let mut centroid = data.get_row_as_vec(rng.gen_range(0..n)); let mut d = vec![T::max_value(); n]; diff --git a/src/ensemble/random_forest_classifier.rs b/src/ensemble/random_forest_classifier.rs index 5d509c0..1d7884b 100644 --- a/src/ensemble/random_forest_classifier.rs +++ b/src/ensemble/random_forest_classifier.rs @@ -265,7 +265,7 @@ impl RandomForestClassifier { let size = ((n_samples as f64) / *class_weight_l) as usize; for _ in 0..size { - let xi: usize = rng.gen_range(0, n_samples); + let xi: usize = rng.gen_range(0..n_samples); samples[index[xi]] += 1; } } diff --git a/src/ensemble/random_forest_regressor.rs b/src/ensemble/random_forest_regressor.rs index 82e299b..0351fc4 100644 --- a/src/ensemble/random_forest_regressor.rs +++ b/src/ensemble/random_forest_regressor.rs @@ -218,7 +218,7 @@ impl RandomForestRegressor { let mut rng = rand::thread_rng(); let mut samples = vec![0; nrows]; for _ in 0..nrows { - let xi = rng.gen_range(0, nrows); + let xi = rng.gen_range(0..nrows); samples[xi] += 1; } samples