Skip to content

Update rand requirement from 0.8.5 to 0.9.1 #296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ cfg-if = "1.0.0"
ndarray = { version = "0.15", optional = true }
num-traits = "0.2.12"
num = "0.4"
rand = { version = "0.8.5", default-features = false, features = ["small_rng"] }
rand = { version = "0.9.1", default-features = false, features = ["small_rng"] }
rand_distr = { version = "0.4", optional = true }
serde = { version = "1", features = ["derive"], optional = true }


Unchanged files with check annotations Beta

fn sample_with_replacement(nrows: usize, rng: &mut impl Rng) -> Vec<usize> {
let mut samples = vec![0; nrows];
for _ in 0..nrows {
let xi = rng.gen_range(0..nrows);

Check warning on line 518 in src/ensemble/random_forest_regressor.rs

GitHub Actions / check_features (ubuntu)

use of deprecated method `rand::Rng::gen_range`: Renamed to `random_range`

Check warning on line 518 in src/ensemble/random_forest_regressor.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

use of deprecated method `rand::Rng::gen_range`: Renamed to `random_range`
samples[xi] += 1;
}
samples
let size = ((n_samples as f64) / *class_weight_l) as usize;
for _ in 0..size {
let xi: usize = rng.gen_range(0..n_samples);

Check warning on line 599 in src/ensemble/random_forest_classifier.rs

GitHub Actions / check_features (ubuntu)

use of deprecated method `rand::Rng::gen_range`: Renamed to `random_range`

Check warning on line 599 in src/ensemble/random_forest_classifier.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

use of deprecated method `rand::Rng::gen_range`: Renamed to `random_range`
samples[index[xi]] += 1;
}
}
let (n, _) = data.shape();
let mut y = vec![0; n];
let mut centroid: Vec<TX> = data
.get_row(rng.gen_range(0..n))

Check warning on line 359 in src/cluster/kmeans.rs

GitHub Actions / check_features (ubuntu)

use of deprecated method `rand::Rng::gen_range`: Renamed to `random_range`

Check failure on line 359 in src/cluster/kmeans.rs

GitHub Actions / lint

use of deprecated method `rand::Rng::gen_range`: Renamed to `random_range`

Check warning on line 359 in src/cluster/kmeans.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

use of deprecated method `rand::Rng::gen_range`: Renamed to `random_range`
.iterator(0)
.cloned()
.collect();
for i in d.iter() {
sum += *i;
}
let cutoff = rng.gen::<f64>() * sum;

Check warning on line 385 in src/cluster/kmeans.rs

GitHub Actions / check_features (ubuntu)

use of deprecated method `rand::Rng::gen`: Renamed to `random` to avoid conflict with the new `gen` keyword in Rust 2024.

Check warning on line 385 in src/cluster/kmeans.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

use of deprecated method `rand::Rng::gen`: Renamed to `random` to avoid conflict with the new `gen` keyword in Rust 2024.
let mut cost = 0f64;
let mut index = 0;
while index < n {
fn rand() -> f64 {
use rand::Rng;
let mut rng = get_rng_impl(None);
rng.gen()

Check warning on line 61 in src/numbers/floatnum.rs

GitHub Actions / check_features (ubuntu)

use of deprecated method `rand::Rng::gen`: Renamed to `random` to avoid conflict with the new `gen` keyword in Rust 2024.

Check failure on line 61 in src/numbers/floatnum.rs

GitHub Actions / lint

use of deprecated method `rand::Rng::gen`: Renamed to `random` to avoid conflict with the new `gen` keyword in Rust 2024.

Check warning on line 61 in src/numbers/floatnum.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

use of deprecated method `rand::Rng::gen`: Renamed to `random` to avoid conflict with the new `gen` keyword in Rust 2024.
}
fn two() -> Self {
fn rand() -> f32 {
use rand::Rng;
let mut rng = get_rng_impl(None);
rng.gen()

Check warning on line 103 in src/numbers/floatnum.rs

GitHub Actions / check_features (ubuntu)

use of deprecated method `rand::Rng::gen`: Renamed to `random` to avoid conflict with the new `gen` keyword in Rust 2024.

Check failure on line 103 in src/numbers/floatnum.rs

GitHub Actions / lint

use of deprecated method `rand::Rng::gen`: Renamed to `random` to avoid conflict with the new `gen` keyword in Rust 2024.

Check warning on line 103 in src/numbers/floatnum.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

use of deprecated method `rand::Rng::gen`: Renamed to `random` to avoid conflict with the new `gen` keyword in Rust 2024.
}
fn two() -> Self {
let mut small_rng = get_rng_impl(None);
let mut rngs: Vec<SmallRng> = (0..3)
.map(|_| SmallRng::from_rng(&mut small_rng).unwrap())

Check failure on line 73 in src/numbers/realnum.rs

GitHub Actions / check_features (ubuntu)

no method named `unwrap` found for struct `SmallRng` in the current scope

Check failure on line 73 in src/numbers/realnum.rs

GitHub Actions / lint

no method named `unwrap` found for struct `rand::prelude::SmallRng` in the current scope

Check failure on line 73 in src/numbers/realnum.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

no method named `unwrap` found for struct `SmallRng` in the current scope
.collect();
rngs[0].gen::<f64>()
}
let mut small_rng = get_rng_impl(None);
let mut rngs: Vec<SmallRng> = (0..3)
.map(|_| SmallRng::from_rng(&mut small_rng).unwrap())

Check failure on line 122 in src/numbers/realnum.rs

GitHub Actions / check_features (ubuntu)

no method named `unwrap` found for struct `SmallRng` in the current scope

Check failure on line 122 in src/numbers/realnum.rs

GitHub Actions / lint

no method named `unwrap` found for struct `rand::prelude::SmallRng` in the current scope

Check failure on line 122 in src/numbers/realnum.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

no method named `unwrap` found for struct `SmallRng` in the current scope
.collect();
rngs[0].gen::<f32>()
}
cfg_if::cfg_if! {
if #[cfg(feature = "std_rand")] {
use rand::RngCore;
RngImpl::seed_from_u64(rand::thread_rng().next_u64())

Check failure on line 15 in src/rand_custom.rs

GitHub Actions / lint

cannot find function `thread_rng` in crate `rand`

Check failure on line 15 in src/rand_custom.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

cannot find function `thread_rng` in crate `rand`
} else {
// no std_random feature build, use getrandom
#[cfg(feature = "js")]
//! # Dataset Generators
//!
use rand::distributions::Uniform;

Check failure on line 3 in src/dataset/generator.rs

GitHub Actions / lint

unresolved import `rand::distributions`

Check failure on line 3 in src/dataset/generator.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

unresolved import `rand::distributions`

Check failure on line 3 in src/dataset/generator.rs

GitHub Actions / coverage

unresolved import `rand::distributions`
use rand::prelude::*;
use rand_distr::Normal;
let cluster_std = 1.0;
let mut centers: Vec<Vec<Normal<f32>>> = Vec::with_capacity(num_centers);
let mut rng = rand::thread_rng();

Check failure on line 19 in src/dataset/generator.rs

GitHub Actions / lint

cannot find function `thread_rng` in crate `rand`

Check failure on line 19 in src/dataset/generator.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

cannot find function `thread_rng` in crate `rand`
for _ in 0..num_centers {
centers.push(
(0..num_features)
let label = i % num_centers;
y.push(label as f32);
for j in 0..num_features {
x.push(centers[label][j].sample(&mut rng));

Check failure on line 35 in src/dataset/generator.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

the method `sample` exists for struct `Normal<f32>`, but its trait bounds were not satisfied
}
}
let linspace_in = linspace(0.0, 2.0 * std::f32::consts::PI, num_samples_in);
let noise = Normal::new(0.0, noise).unwrap();
let mut rng = rand::thread_rng();

Check failure on line 63 in src/dataset/generator.rs

GitHub Actions / lint

cannot find function `thread_rng` in crate `rand`

Check failure on line 63 in src/dataset/generator.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

cannot find function `thread_rng` in crate `rand`
let mut x: Vec<f32> = Vec::with_capacity(num_samples * 2);
let mut y: Vec<f32> = Vec::with_capacity(num_samples);
for v in linspace_out {
x.push(v.cos() + noise.sample(&mut rng));

Check failure on line 69 in src/dataset/generator.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

the method `sample` exists for struct `Normal<f32>`, but its trait bounds were not satisfied
x.push(v.sin() + noise.sample(&mut rng));

Check failure on line 70 in src/dataset/generator.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

the method `sample` exists for struct `Normal<f32>`, but its trait bounds were not satisfied
y.push(0.0);
}
let linspace_in = linspace(0.0, std::f32::consts::PI, num_samples_in);
let noise = Normal::new(0.0, noise).unwrap();
let mut rng = rand::thread_rng();

Check failure on line 100 in src/dataset/generator.rs

GitHub Actions / lint

cannot find function `thread_rng` in crate `rand`

Check failure on line 100 in src/dataset/generator.rs

GitHub Actions / tests (macos, aarch64-apple-darwin)

cannot find function `thread_rng` in crate `rand`
let mut x: Vec<f32> = Vec::with_capacity(num_samples * 2);
let mut y: Vec<f32> = Vec::with_capacity(num_samples);