Skip to content

Commit 37e4070

Browse files
committed
rand: Update ndarray-rand to rand 0.8
Also edit docs and links in docs. Remove some instances of versioned links (we can't have too many places where we need to update the version for each new version of rand). Update ndarray-rand quickcheck after rand update (quickcheck is still on rand 0.7, but the rest of the crate uses rand 0.8) Update numeric-tests to rand 0.8
1 parent fa35a35 commit 37e4070

File tree

4 files changed

+30
-31
lines changed

4 files changed

+30
-31
lines changed

ndarray-rand/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ keywords = ["multidimensional", "matrix", "rand", "ndarray"]
1515

1616
[dependencies]
1717
ndarray = { version = "0.14", path = ".." }
18-
rand_distr = "0.3.0"
18+
rand_distr = "0.4.0"
1919
quickcheck = { version = "0.9", default-features = false, optional = true }
2020

2121
[dependencies.rand]
22-
version = "0.7.0"
22+
version = "0.8.0"
2323
features = ["small_rng"]
2424

2525
[dev-dependencies]
26-
rand_isaac = "0.2.0"
26+
rand_isaac = "0.3.0"
2727
quickcheck = { version = "0.9", default-features = false }
2828

2929
[package.metadata.release]

ndarray-rand/src/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
//!
1313
//! ## Note
1414
//!
15-
//! `ndarray-rand` depends on [`rand` 0.7][rand].
15+
//! `ndarray-rand` depends on [`rand` 0.8][rand].
1616
//!
1717
//! [`rand`][rand] and [`rand_distr`][rand_distr]
1818
//! are re-exported as sub-modules, [`ndarray_rand::rand`](rand/index.html)
1919
//! and [`ndarray_rand::rand_distr`](rand_distr/index.html) respectively.
2020
//! You can use these submodules for guaranteed version compatibility or
2121
//! convenience.
2222
//!
23-
//! [rand]: https://docs.rs/rand/0.7
24-
//! [rand_distr]: https://docs.rs/rand_distr/0.3
23+
//! [rand]: https://docs.rs/rand/0.8
24+
//! [rand_distr]: https://docs.rs/rand_distr/0.4
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
@@ -39,12 +39,12 @@ use ndarray::{ArrayBase, DataOwned, Dimension};
3939
#[cfg(feature = "quickcheck")]
4040
use quickcheck::{Arbitrary, Gen};
4141

42-
/// [`rand`](https://docs.rs/rand/0.7), re-exported for convenience and version-compatibility.
42+
/// `rand`, re-exported for convenience and version-compatibility.
4343
pub mod rand {
4444
pub use rand::*;
4545
}
4646

47-
/// [`rand-distr`](https://docs.rs/rand_distr/0.3), re-exported for convenience and version-compatibility.
47+
/// `rand-distr`, re-exported for convenience and version-compatibility.
4848
pub mod rand_distr {
4949
pub use rand_distr::*;
5050
}
@@ -55,8 +55,7 @@ pub mod rand_distr {
5555
/// for other types.
5656
///
5757
/// The default RNG is a fast automatically seeded rng (currently
58-
/// [`rand::rngs::SmallRng`](https://docs.rs/rand/0.7/rand/rngs/struct.SmallRng.html)
59-
/// seeded from [`rand::thread_rng`](https://docs.rs/rand/0.7/rand/fn.thread_rng.html)).
58+
/// [`rand::rngs::SmallRng`], seeded from [`rand::thread_rng`]).
6059
///
6160
/// Note that `SmallRng` is cheap to initialize and fast, but it may generate
6261
/// low-quality random numbers, and reproducibility is not guaranteed. See its
@@ -298,7 +297,7 @@ pub enum SamplingStrategy {
298297
#[cfg(feature = "quickcheck")]
299298
impl Arbitrary for SamplingStrategy {
300299
fn arbitrary<G: Gen>(g: &mut G) -> Self {
301-
if g.gen_bool(0.5) {
300+
if bool::arbitrary(g) {
302301
SamplingStrategy::WithReplacement
303302
} else {
304303
SamplingStrategy::WithoutReplacement

numeric-tests/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ publish = false
88
approx = "0.4"
99
ndarray = { path = "..", features = ["approx"] }
1010
ndarray-rand = { path = "../ndarray-rand/" }
11-
rand_distr = "0.3"
11+
rand_distr = "0.4"
1212

1313
[dependencies.rand]
14-
version = "0.7.0"
14+
version = "0.8.0"
1515
features = ["small_rng"]
1616

1717
[lib]

numeric-tests/tests/accuracy.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ fn accurate_eye_f32() {
7676
// pick a few random sizes
7777
let mut rng = SmallRng::from_entropy();
7878
for _ in 0..10 {
79-
let i = rng.gen_range(15, 512);
80-
let j = rng.gen_range(15, 512);
79+
let i = rng.gen_range(15..512);
80+
let j = rng.gen_range(15..512);
8181
println!("Testing size {} by {}", i, j);
8282
let a = gen(Ix2(i, j));
8383
let eye = Array::eye(i);
@@ -104,8 +104,8 @@ fn accurate_eye_f64() {
104104
// pick a few random sizes
105105
let mut rng = SmallRng::from_entropy();
106106
for _ in 0..10 {
107-
let i = rng.gen_range(15, 512);
108-
let j = rng.gen_range(15, 512);
107+
let i = rng.gen_range(15..512);
108+
let j = rng.gen_range(15..512);
109109
println!("Testing size {} by {}", i, j);
110110
let a = gen_f64(Ix2(i, j));
111111
let eye = Array::eye(i);
@@ -121,9 +121,9 @@ fn accurate_mul_f32() {
121121
// pick a few random sizes
122122
let mut rng = SmallRng::from_entropy();
123123
for i in 0..20 {
124-
let m = rng.gen_range(15, 512);
125-
let k = rng.gen_range(15, 512);
126-
let n = rng.gen_range(15, 1560);
124+
let m = rng.gen_range(15..512);
125+
let k = rng.gen_range(15..512);
126+
let n = rng.gen_range(15..1560);
127127
let a = gen(Ix2(m, k));
128128
let b = gen(Ix2(n, k));
129129
let b = b.t();
@@ -145,9 +145,9 @@ fn accurate_mul_f32_general() {
145145
// pick a few random sizes
146146
let mut rng = SmallRng::from_entropy();
147147
for i in 0..20 {
148-
let m = rng.gen_range(15, 512);
149-
let k = rng.gen_range(15, 512);
150-
let n = rng.gen_range(15, 1560);
148+
let m = rng.gen_range(15..512);
149+
let k = rng.gen_range(15..512);
150+
let n = rng.gen_range(15..1560);
151151
let a = gen(Ix2(m, k));
152152
let b = gen(Ix2(n, k));
153153
let mut c = gen(Ix2(m, n));
@@ -171,9 +171,9 @@ fn accurate_mul_f64() {
171171
// pick a few random sizes
172172
let mut rng = SmallRng::from_entropy();
173173
for i in 0..20 {
174-
let m = rng.gen_range(15, 512);
175-
let k = rng.gen_range(15, 512);
176-
let n = rng.gen_range(15, 1560);
174+
let m = rng.gen_range(15..512);
175+
let k = rng.gen_range(15..512);
176+
let n = rng.gen_range(15..1560);
177177
let a = gen_f64(Ix2(m, k));
178178
let b = gen_f64(Ix2(n, k));
179179
let b = b.t();
@@ -195,9 +195,9 @@ fn accurate_mul_f64_general() {
195195
// pick a few random sizes
196196
let mut rng = SmallRng::from_entropy();
197197
for i in 0..20 {
198-
let m = rng.gen_range(15, 512);
199-
let k = rng.gen_range(15, 512);
200-
let n = rng.gen_range(15, 1560);
198+
let m = rng.gen_range(15..512);
199+
let k = rng.gen_range(15..512);
200+
let n = rng.gen_range(15..1560);
201201
let a = gen_f64(Ix2(m, k));
202202
let b = gen_f64(Ix2(n, k));
203203
let mut c = gen_f64(Ix2(m, n));
@@ -221,8 +221,8 @@ fn accurate_mul_with_column_f64() {
221221
// pick a few random sizes
222222
let mut rng = SmallRng::from_entropy();
223223
for i in 0..10 {
224-
let m = rng.gen_range(1, 350);
225-
let k = rng.gen_range(1, 350);
224+
let m = rng.gen_range(1..350);
225+
let k = rng.gen_range(1..350);
226226
let a = gen_f64(Ix2(m, k));
227227
let b_owner = gen_f64(Ix2(k, k));
228228
let b_row_col;

0 commit comments

Comments
 (0)