Skip to content

Commit c9fe937

Browse files
authored
feat: update to rand 0.10 and rand_distr 0.6
No changes needed in ndarray-rand itself. Changes in `crates/numeric-tests/tests/accuracy.rs`: - Import `RngExt` for `random_range`. - Replace the removed `SmallRng::from_os_rng` with `SmallRng::from_rng(&mut rand::rng())`. bump ndarray-rand to 0.17.0 Closes #1590
1 parent 4ada8b9 commit c9fe937

8 files changed

Lines changed: 49 additions & 24 deletions

File tree

‎Cargo.lock‎

Lines changed: 30 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ num-complex = { version = "0.4", default-features = false }
105105
approx = { version = "0.5", default-features = false }
106106
quickcheck = { version = "1.0", default-features = false }
107107
proptest = { version = "1.3.1" }
108-
rand = { version = "0.9.0", features = ["small_rng"] }
109-
rand_distr = { version = "0.5.0" }
108+
rand = { version = "0.10.0" }
109+
rand_distr = { version = "0.6.0" }
110110
itertools = { version = "0.13.0", default-features = false, features = ["use_std"] }
111111
cblas-sys = { version = "0.1.4", default-features = false }
112112

‎README-quick-start.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ use std::iter::FromIterator;
305305

306306
fn main() {
307307
// Or you may use ndarray_rand crate to generate random arrays
308-
// let a = Array::random((2, 5), Uniform::new(0., 10.));
308+
// let a = Array::random((2, 5), Uniform::new(0., 10.).unwrap());
309309

310310
let a = array![
311311
[3., 7., 3., 4.],

‎crates/numeric-tests/tests/accuracy.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::fmt;
1010

1111
use ndarray_rand::RandomExt;
1212
use rand::rngs::SmallRng;
13-
use rand::{Rng, SeedableRng};
13+
use rand::{RngExt, SeedableRng};
1414

1515
use ndarray::linalg::general_mat_mul;
1616
use ndarray::prelude::*;
@@ -86,7 +86,7 @@ where
8686
#[test]
8787
fn accurate_eye_f32()
8888
{
89-
let rng = &mut SmallRng::from_os_rng();
89+
let rng = &mut SmallRng::from_rng(&mut rand::rng());
9090
for i in 0..20 {
9191
let eye = Array::eye(i);
9292
for j in 0..20 {
@@ -114,7 +114,7 @@ fn accurate_eye_f32()
114114
#[test]
115115
fn accurate_eye_f64()
116116
{
117-
let rng = &mut SmallRng::from_os_rng();
117+
let rng = &mut SmallRng::from_rng(&mut rand::rng());
118118
let abs_tol = 1e-15;
119119
for i in 0..20 {
120120
let eye = Array::eye(i);
@@ -209,7 +209,7 @@ where
209209
A: fmt::Debug,
210210
{
211211
// pick a few random sizes
212-
let mut rng = SmallRng::from_os_rng();
212+
let mut rng = SmallRng::from_rng(&mut rand::rng());
213213
for i in 0..20 {
214214
let (c, reference) = random_matrix_mul(&mut rng, i > 10, use_general, gen::<A, _>);
215215

@@ -241,7 +241,7 @@ where
241241
A: fmt::Debug,
242242
{
243243
// pick a few random sizes
244-
let mut rng = SmallRng::from_os_rng();
244+
let mut rng = SmallRng::from_rng(&mut rand::rng());
245245
for i in 0..20 {
246246
let (c, reference) = random_matrix_mul(&mut rng, i > 10, true, gen_complex::<A, _>);
247247

@@ -259,7 +259,7 @@ where
259259
fn accurate_mul_with_column_f64()
260260
{
261261
// pick a few random sizes
262-
let rng = &mut SmallRng::from_os_rng();
262+
let rng = &mut SmallRng::from_rng(&mut rand::rng());
263263
for i in 0..10 {
264264
let m = rng.random_range(1..128);
265265
let k = rng.random_range(1..350);

‎ndarray-rand/Cargo.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ndarray-rand"
3-
version = "0.16.0"
3+
version = "0.17.0"
44
edition = "2018"
55
authors = ["bluss"]
66
license = "MIT OR Apache-2.0"
@@ -29,7 +29,7 @@ rand_distr = { workspace = true }
2929
quickcheck = { workspace = true, optional = true }
3030

3131
[dev-dependencies]
32-
rand_isaac = "0.4.0"
32+
rand_isaac = "0.5.0"
3333
quickcheck = { workspace = true }
3434

3535
[package.metadata.release]

‎ndarray-rand/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use ndarray_rand::RandomExt;
1515
use ndarray_rand::rand_distr::Uniform;
1616

1717
fn main() {
18-
let a = Array::random((2, 5), Uniform::new(0., 10.));
18+
let a = Array::random((2, 5), Uniform::new(0., 10.).unwrap());
1919
println!("{:8.4}", a);
2020
// Example Output:
2121
// [[ 8.6900, 6.9824, 3.8922, 6.5861, 2.4890],

‎ndarray-rand/RELEASES.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Recent Changes
22
--------------
33

4+
- 0.17.0
5+
6+
- Bump `rand` to 0.10.0 and `rand_distr` to 0.6.0
7+
48
- 0.16.0
59

610
- Require ndarray 0.17.1

‎ndarray-rand/src/lib.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
//!
1313
//! ## Note
1414
//!
15-
//! `ndarray-rand` depends on [`rand` 0.9][rand].
15+
//! `ndarray-rand` depends on [`rand` 0.10][rand].
1616
//!
1717
//! [`rand`][rand] and [`rand_distr`][rand_distr]
1818
//! are re-exported as sub-modules, [`ndarray_rand::rand`](rand)
1919
//! and [`ndarray_rand::rand_distr`](rand_distr) respectively.
2020
//! You can use these submodules for guaranteed version compatibility or
2121
//! convenience.
2222
//!
23-
//! [rand]: https://docs.rs/rand/0.9
24-
//! [rand_distr]: https://docs.rs/rand_distr/0.5
23+
//! [rand]: https://docs.rs/rand/0.10
24+
//! [rand_distr]: https://docs.rs/rand_distr/0.6
2525
//!
2626
//! If you want to use a random number generator or distribution from another crate
2727
//! with `ndarray-rand`, you need to make sure that the other crate also depends on the

0 commit comments

Comments
 (0)