Skip to content

Commit

Permalink
Update rand to 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
msk committed Feb 23, 2025
1 parent 24f0d41 commit 332f528
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Versioning](https://semver.org/spec/v2.0.0.html).
### Changed

* Requires Rust 1.71.1 or later.
* Updated rand to 0.9.

## [0.8.0] - 2024-11-01

Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ serialization = [
"serde",
"lair/serialization",
"ndarray/serde",
"rand/serde1",
"rand_pcg/serde1",
"rand/serde",
"rand_pcg/serde",
]

[dependencies]
Expand All @@ -56,9 +56,9 @@ lapack = "0.19"
ndarray = "0.16.1"
num-complex = "0.4"
num-traits = "0.2.15"
rand = "0.8"
rand_distr = "0.4"
rand_pcg = "0.3"
rand = "0.9"
rand_distr = "0.5"
rand_pcg = "0.9"
serde = { version = "1", features = ["derive"], optional = true }
thiserror = "2"

Expand Down
6 changes: 3 additions & 3 deletions src/ica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ where
/// initialized with a randomly-generated seed.
#[must_use]
pub fn new() -> Self {
let seed: u128 = rand::thread_rng().gen();
let seed: u128 = rand::rng().random();
Self::with_seed(seed)
}

Expand Down Expand Up @@ -251,7 +251,7 @@ impl FastIcaBuilder<Pcg> {
/// initialized with a randomly-generated seed.
#[must_use]
pub fn new() -> Self {
let seed: u128 = rand::thread_rng().gen();
let seed: u128 = rand::rng().random();
Self {
rng: Pcg::from_seed(seed.to_be_bytes()),
}
Expand Down Expand Up @@ -307,7 +307,7 @@ impl<R: Rng> FastIcaBuilder<R> {

impl Default for FastIcaBuilder<Pcg> {
fn default() -> Self {
let seed: u128 = rand::thread_rng().gen();
let seed: u128 = rand::rng().random();
Self {
rng: Pcg::from_seed(seed.to_be_bytes()),
}
Expand Down
8 changes: 4 additions & 4 deletions src/pca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ where
/// randomly-generated seed.
#[must_use]
pub fn new(n_components: usize) -> Self {
let seed: u128 = rand::thread_rng().gen();
let seed: u128 = rand::rng().random();
Self::with_seed(n_components, seed)
}

Expand Down Expand Up @@ -574,7 +574,7 @@ impl RandomizedPcaBuilder<Pcg> {
/// randomly-generated seed.
#[must_use]
pub fn new(n_components: usize) -> Self {
let seed: u128 = rand::thread_rng().gen();
let seed: u128 = rand::rng().random();
Self {
n_components,
rng: Pcg::from_seed(seed.to_be_bytes()),
Expand Down Expand Up @@ -960,7 +960,7 @@ mod test {
let z = pca.inverse_transform(&y).expect("valid input");
assert!(z.abs_diff_eq(&x, 1e-10));

let mut pca = super::RandomizedPca::with_rng(1, rand::thread_rng());
let mut pca = super::RandomizedPca::with_rng(1, rand::rng());
let y = pca.fit_transform(&x).unwrap();
assert_abs_diff_eq!(y[(0, 0)].abs(), 5., epsilon = 1e-10);
assert_abs_diff_eq!(y[(1, 0)], 0., epsilon = 1e-10);
Expand All @@ -977,7 +977,7 @@ mod test {
[2_f64, 1_f64],
[3_f64, 2_f64],
]);
let mut pca = super::RandomizedPca::with_rng(2, rand::thread_rng());
let mut pca = super::RandomizedPca::with_rng(2, rand::rng());
assert!(pca.fit(&x).is_ok());
let ratio = pca.explained_variance_ratio();
assert!(ratio.get(0).unwrap() > &0.99244);
Expand Down

0 comments on commit 332f528

Please sign in to comment.