Skip to content

Commit

Permalink
rand: Update ndarray-rand to rand 0.8
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bluss committed Dec 21, 2020
1 parent fa35a35 commit 37e4070
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 31 deletions.
6 changes: 3 additions & 3 deletions ndarray-rand/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ keywords = ["multidimensional", "matrix", "rand", "ndarray"]

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

[dependencies.rand]
version = "0.7.0"
version = "0.8.0"
features = ["small_rng"]

[dev-dependencies]
rand_isaac = "0.2.0"
rand_isaac = "0.3.0"
quickcheck = { version = "0.9", default-features = false }

[package.metadata.release]
Expand Down
15 changes: 7 additions & 8 deletions ndarray-rand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
//!
//! ## Note
//!
//! `ndarray-rand` depends on [`rand` 0.7][rand].
//! `ndarray-rand` depends on [`rand` 0.8][rand].
//!
//! [`rand`][rand] and [`rand_distr`][rand_distr]
//! are re-exported as sub-modules, [`ndarray_rand::rand`](rand/index.html)
//! and [`ndarray_rand::rand_distr`](rand_distr/index.html) respectively.
//! You can use these submodules for guaranteed version compatibility or
//! convenience.
//!
//! [rand]: https://docs.rs/rand/0.7
//! [rand_distr]: https://docs.rs/rand_distr/0.3
//! [rand]: https://docs.rs/rand/0.8
//! [rand_distr]: https://docs.rs/rand_distr/0.4
//!
//! If you want to use a random number generator or distribution from another crate
//! with `ndarray-rand`, you need to make sure that the other crate also depends on the
Expand All @@ -39,12 +39,12 @@ use ndarray::{ArrayBase, DataOwned, Dimension};
#[cfg(feature = "quickcheck")]
use quickcheck::{Arbitrary, Gen};

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

/// [`rand-distr`](https://docs.rs/rand_distr/0.3), re-exported for convenience and version-compatibility.
/// `rand-distr`, re-exported for convenience and version-compatibility.
pub mod rand_distr {
pub use rand_distr::*;
}
Expand All @@ -55,8 +55,7 @@ pub mod rand_distr {
/// for other types.
///
/// The default RNG is a fast automatically seeded rng (currently
/// [`rand::rngs::SmallRng`](https://docs.rs/rand/0.7/rand/rngs/struct.SmallRng.html)
/// seeded from [`rand::thread_rng`](https://docs.rs/rand/0.7/rand/fn.thread_rng.html)).
/// [`rand::rngs::SmallRng`], seeded from [`rand::thread_rng`]).
///
/// Note that `SmallRng` is cheap to initialize and fast, but it may generate
/// low-quality random numbers, and reproducibility is not guaranteed. See its
Expand Down Expand Up @@ -298,7 +297,7 @@ pub enum SamplingStrategy {
#[cfg(feature = "quickcheck")]
impl Arbitrary for SamplingStrategy {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
if g.gen_bool(0.5) {
if bool::arbitrary(g) {
SamplingStrategy::WithReplacement
} else {
SamplingStrategy::WithoutReplacement
Expand Down
4 changes: 2 additions & 2 deletions numeric-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ publish = false
approx = "0.4"
ndarray = { path = "..", features = ["approx"] }
ndarray-rand = { path = "../ndarray-rand/" }
rand_distr = "0.3"
rand_distr = "0.4"

[dependencies.rand]
version = "0.7.0"
version = "0.8.0"
features = ["small_rng"]

[lib]
Expand Down
36 changes: 18 additions & 18 deletions numeric-tests/tests/accuracy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ fn accurate_eye_f32() {
// pick a few random sizes
let mut rng = SmallRng::from_entropy();
for _ in 0..10 {
let i = rng.gen_range(15, 512);
let j = rng.gen_range(15, 512);
let i = rng.gen_range(15..512);
let j = rng.gen_range(15..512);
println!("Testing size {} by {}", i, j);
let a = gen(Ix2(i, j));
let eye = Array::eye(i);
Expand All @@ -104,8 +104,8 @@ fn accurate_eye_f64() {
// pick a few random sizes
let mut rng = SmallRng::from_entropy();
for _ in 0..10 {
let i = rng.gen_range(15, 512);
let j = rng.gen_range(15, 512);
let i = rng.gen_range(15..512);
let j = rng.gen_range(15..512);
println!("Testing size {} by {}", i, j);
let a = gen_f64(Ix2(i, j));
let eye = Array::eye(i);
Expand All @@ -121,9 +121,9 @@ fn accurate_mul_f32() {
// pick a few random sizes
let mut rng = SmallRng::from_entropy();
for i in 0..20 {
let m = rng.gen_range(15, 512);
let k = rng.gen_range(15, 512);
let n = rng.gen_range(15, 1560);
let m = rng.gen_range(15..512);
let k = rng.gen_range(15..512);
let n = rng.gen_range(15..1560);
let a = gen(Ix2(m, k));
let b = gen(Ix2(n, k));
let b = b.t();
Expand All @@ -145,9 +145,9 @@ fn accurate_mul_f32_general() {
// pick a few random sizes
let mut rng = SmallRng::from_entropy();
for i in 0..20 {
let m = rng.gen_range(15, 512);
let k = rng.gen_range(15, 512);
let n = rng.gen_range(15, 1560);
let m = rng.gen_range(15..512);
let k = rng.gen_range(15..512);
let n = rng.gen_range(15..1560);
let a = gen(Ix2(m, k));
let b = gen(Ix2(n, k));
let mut c = gen(Ix2(m, n));
Expand All @@ -171,9 +171,9 @@ fn accurate_mul_f64() {
// pick a few random sizes
let mut rng = SmallRng::from_entropy();
for i in 0..20 {
let m = rng.gen_range(15, 512);
let k = rng.gen_range(15, 512);
let n = rng.gen_range(15, 1560);
let m = rng.gen_range(15..512);
let k = rng.gen_range(15..512);
let n = rng.gen_range(15..1560);
let a = gen_f64(Ix2(m, k));
let b = gen_f64(Ix2(n, k));
let b = b.t();
Expand All @@ -195,9 +195,9 @@ fn accurate_mul_f64_general() {
// pick a few random sizes
let mut rng = SmallRng::from_entropy();
for i in 0..20 {
let m = rng.gen_range(15, 512);
let k = rng.gen_range(15, 512);
let n = rng.gen_range(15, 1560);
let m = rng.gen_range(15..512);
let k = rng.gen_range(15..512);
let n = rng.gen_range(15..1560);
let a = gen_f64(Ix2(m, k));
let b = gen_f64(Ix2(n, k));
let mut c = gen_f64(Ix2(m, n));
Expand All @@ -221,8 +221,8 @@ fn accurate_mul_with_column_f64() {
// pick a few random sizes
let mut rng = SmallRng::from_entropy();
for i in 0..10 {
let m = rng.gen_range(1, 350);
let k = rng.gen_range(1, 350);
let m = rng.gen_range(1..350);
let k = rng.gen_range(1..350);
let a = gen_f64(Ix2(m, k));
let b_owner = gen_f64(Ix2(k, k));
let b_row_col;
Expand Down

0 comments on commit 37e4070

Please sign in to comment.