From b5da2714a545997dbab206789b117721493f687c Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Wed, 17 Jul 2019 17:27:05 -0400 Subject: [PATCH 01/17] upgrade to rand 0.7.0 --- ndarray-rand/Cargo.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ndarray-rand/Cargo.toml b/ndarray-rand/Cargo.toml index 1199fee9d..7209f88c6 100644 --- a/ndarray-rand/Cargo.toml +++ b/ndarray-rand/Cargo.toml @@ -12,9 +12,12 @@ description = "Constructors for randomized arrays. `rand` integration for `ndarr keywords = ["multidimensional", "matrix", "rand", "ndarray"] [dependencies] -rand = "0.6.0" ndarray = { version = "0.12.0", path = ".." } +[dependencies.rand] +version = "0.7.0" +features = ["small_rng"] + [package.metadata.release] no-dev-version = true From fd307bea7decb5bb2cf6d052c7105d3badfabe25 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 18 Jul 2019 13:30:26 -0400 Subject: [PATCH 02/17] move benches to rand_distr --- ndarray-rand/Cargo.toml | 1 + ndarray-rand/benches/bench.rs | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ndarray-rand/Cargo.toml b/ndarray-rand/Cargo.toml index 7209f88c6..76c5a78ca 100644 --- a/ndarray-rand/Cargo.toml +++ b/ndarray-rand/Cargo.toml @@ -13,6 +13,7 @@ keywords = ["multidimensional", "matrix", "rand", "ndarray"] [dependencies] ndarray = { version = "0.12.0", path = ".." } +rand_distr = "0.2.1" [dependencies.rand] version = "0.7.0" diff --git a/ndarray-rand/benches/bench.rs b/ndarray-rand/benches/bench.rs index 8d47b7b3f..66fd877f4 100644 --- a/ndarray-rand/benches/bench.rs +++ b/ndarray-rand/benches/bench.rs @@ -8,7 +8,7 @@ extern crate test; use ndarray::Array; use ndarray_rand::RandomExt; use ndarray_rand::F32; -use rand::distributions::Normal; +use rand_distr::Normal; use rand::distributions::Uniform; use test::Bencher; @@ -17,8 +17,7 @@ use test::Bencher; fn uniform_f32(b: &mut Bencher) { let m = 100; b.iter(|| { - let a = Array::random((m, m), Uniform::new(-1f32, 1.)); - a + Array::random((m, m), Uniform::new(-1f32, 1.)) }); } @@ -26,8 +25,7 @@ fn uniform_f32(b: &mut Bencher) { fn norm_f32(b: &mut Bencher) { let m = 100; b.iter(|| { - let a = Array::random((m, m), F32(Normal::new(0., 1.))); - a + Array::random((m, m), F32(Normal::new(0., 1.))) }); } @@ -35,7 +33,6 @@ fn norm_f32(b: &mut Bencher) { fn norm_f64(b: &mut Bencher) { let m = 100; b.iter(|| { - let a = Array::random((m, m), Normal::new(0., 1.)); - a + Array::random((m, m), Normal::new(0., 1.)) }); } From b5302462de1119fa8b7fcc237c2d4a5d7a23ec22 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 18 Jul 2019 13:43:19 -0400 Subject: [PATCH 03/17] upgrade rand in numeric-tests too --- numeric-tests/Cargo.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/numeric-tests/Cargo.toml b/numeric-tests/Cargo.toml index 79e525c83..dc1261512 100644 --- a/numeric-tests/Cargo.toml +++ b/numeric-tests/Cargo.toml @@ -8,7 +8,11 @@ publish = false approx = "0.3.2" ndarray = { path = "..", features = ["approx"] } ndarray-rand = { path = "../ndarray-rand/" } -rand = "0.6.0" +rand_distr = "0.2.1" + +[dependencies.rand] +version = "0.7.0" +features = ["small_rng"] [lib] test = false From 1c4bf65974361e939cbe941b04068092b0d317e0 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 18 Jul 2019 14:14:47 -0400 Subject: [PATCH 04/17] not sure why we need extern crate but it seems we do?! --- ndarray-rand/benches/bench.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/ndarray-rand/benches/bench.rs b/ndarray-rand/benches/bench.rs index 66fd877f4..7056aaf46 100644 --- a/ndarray-rand/benches/bench.rs +++ b/ndarray-rand/benches/bench.rs @@ -3,6 +3,7 @@ extern crate ndarray; extern crate ndarray_rand; extern crate rand; +extern crate rand_distr; extern crate test; use ndarray::Array; From 1462c5e1bd67137e6baacdb5cf5a76f1f5ebb1aa Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 18 Jul 2019 14:26:13 -0400 Subject: [PATCH 05/17] cargo fmt --- ndarray-rand/benches/bench.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/ndarray-rand/benches/bench.rs b/ndarray-rand/benches/bench.rs index 7056aaf46..10c0a71e5 100644 --- a/ndarray-rand/benches/bench.rs +++ b/ndarray-rand/benches/bench.rs @@ -9,31 +9,25 @@ extern crate test; use ndarray::Array; use ndarray_rand::RandomExt; use ndarray_rand::F32; -use rand_distr::Normal; use rand::distributions::Uniform; +use rand_distr::Normal; use test::Bencher; #[bench] fn uniform_f32(b: &mut Bencher) { let m = 100; - b.iter(|| { - Array::random((m, m), Uniform::new(-1f32, 1.)) - }); + b.iter(|| Array::random((m, m), Uniform::new(-1f32, 1.))); } #[bench] fn norm_f32(b: &mut Bencher) { let m = 100; - b.iter(|| { - Array::random((m, m), F32(Normal::new(0., 1.))) - }); + b.iter(|| Array::random((m, m), F32(Normal::new(0., 1.)))); } #[bench] fn norm_f64(b: &mut Bencher) { let m = 100; - b.iter(|| { - Array::random((m, m), Normal::new(0., 1.)) - }); + b.iter(|| Array::random((m, m), Normal::new(0., 1.))); } From 4254365aadf0b1e72ba9b6d3186256747e1c499d Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 18 Jul 2019 15:06:01 -0400 Subject: [PATCH 06/17] move distributions to rand_distr --- ndarray-rand/benches/bench.rs | 2 +- ndarray-rand/src/lib.rs | 3 ++- ndarray-rand/tests/tests.rs | 2 +- numeric-tests/tests/accuracy.rs | 5 +++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ndarray-rand/benches/bench.rs b/ndarray-rand/benches/bench.rs index 10c0a71e5..b356d00e5 100644 --- a/ndarray-rand/benches/bench.rs +++ b/ndarray-rand/benches/bench.rs @@ -9,8 +9,8 @@ extern crate test; use ndarray::Array; use ndarray_rand::RandomExt; use ndarray_rand::F32; -use rand::distributions::Uniform; use rand_distr::Normal; +use rand_distr::Uniform; use test::Bencher; diff --git a/ndarray-rand/src/lib.rs b/ndarray-rand/src/lib.rs index 3ac9486f9..0b277f24c 100644 --- a/ndarray-rand/src/lib.rs +++ b/ndarray-rand/src/lib.rs @@ -11,10 +11,11 @@ //! See [**`RandomExt`**](trait.RandomExt.html) for usage examples. extern crate ndarray; extern crate rand; +extern crate rand_distr; -use rand::distributions::Distribution; use rand::rngs::SmallRng; use rand::{thread_rng, Rng, SeedableRng}; +use rand_distr::Distribution; use ndarray::ShapeBuilder; use ndarray::{ArrayBase, DataOwned, Dimension}; diff --git a/ndarray-rand/tests/tests.rs b/ndarray-rand/tests/tests.rs index 621bd9d97..3ffa89928 100644 --- a/ndarray-rand/tests/tests.rs +++ b/ndarray-rand/tests/tests.rs @@ -4,7 +4,7 @@ extern crate rand; use ndarray::Array; use ndarray_rand::RandomExt; -use rand::distributions::Uniform; +use rand_distr::Uniform; #[test] fn test_dim() { diff --git a/numeric-tests/tests/accuracy.rs b/numeric-tests/tests/accuracy.rs index f2b278909..1ae2aa627 100644 --- a/numeric-tests/tests/accuracy.rs +++ b/numeric-tests/tests/accuracy.rs @@ -1,10 +1,11 @@ extern crate approx; +extern crate rand_distr; extern crate ndarray; extern crate ndarray_rand; extern crate rand; use ndarray_rand::{RandomExt, F32}; -use rand::{FromEntropy, Rng}; +use rand::{Rng, SeedableRng}; use rand::rngs::SmallRng; use ndarray::prelude::*; @@ -14,7 +15,7 @@ use ndarray::{ }; use ndarray::linalg::general_mat_mul; -use rand::distributions::Normal; +use rand_distr::Normal; use approx::{assert_abs_diff_eq, assert_relative_eq}; From 9e934ed450b3706c28c441e3e8e05603a9f23571 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 18 Jul 2019 15:45:01 -0400 Subject: [PATCH 07/17] Normal now returns Result --- numeric-tests/tests/accuracy.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numeric-tests/tests/accuracy.rs b/numeric-tests/tests/accuracy.rs index 1ae2aa627..4f61248df 100644 --- a/numeric-tests/tests/accuracy.rs +++ b/numeric-tests/tests/accuracy.rs @@ -53,12 +53,12 @@ fn reference_mat_mul(lhs: &ArrayBase, rhs: &ArrayBase fn gen(d: D) -> Array where D: Dimension, { - Array::random(d, F32(Normal::new(0., 1.))) + Array::random(d, F32(Normal::new(0., 1.).unwrap())) } fn gen_f64(d: D) -> Array where D: Dimension, { - Array::random(d, Normal::new(0., 1.)) + Array::random(d, Normal::new(0., 1.).unwrap()) } #[test] From 717d94277c74a16a00a6a7ed1be76d74a7df4c59 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 18 Jul 2019 15:59:57 -0400 Subject: [PATCH 08/17] bump ndarray-rand to 0.10.0 --- ndarray-rand/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndarray-rand/Cargo.toml b/ndarray-rand/Cargo.toml index 76c5a78ca..9587940f4 100644 --- a/ndarray-rand/Cargo.toml +++ b/ndarray-rand/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ndarray-rand" -version = "0.9.0" +version = "0.10.0" authors = ["bluss"] license = "MIT/Apache-2.0" From 00a6619052c1d0b2c29906c5314970573a0377d8 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 18 Jul 2019 16:05:44 -0400 Subject: [PATCH 09/17] bump required rust to 1.32 because of getrandom --- .travis.yml | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e32f2c62e..618733951 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ sudo: required dist: trusty matrix: include: - - rust: 1.31.0 + - rust: 1.32.0 env: - FEATURES='test docs' - rust: stable diff --git a/src/lib.rs b/src/lib.rs index 53ffa3480..71a838219 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,7 +61,7 @@ //! needs matching memory layout to be efficient (with some exceptions). //! + Efficient floating point matrix multiplication even for very large //! matrices; can optionally use BLAS to improve it further. -//! - **Requires Rust 1.31** +//! - **Requires Rust 1.32** //! //! ## Crate Feature Flags //! From 0ae37881589112c9d5af3780c483f49a3755cfb8 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Mon, 22 Jul 2019 13:00:40 -0400 Subject: [PATCH 10/17] rand_distr to dev dependencies --- ndarray-rand/Cargo.toml | 4 +++- ndarray-rand/src/lib.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ndarray-rand/Cargo.toml b/ndarray-rand/Cargo.toml index 1a1bbea8b..27e76df17 100644 --- a/ndarray-rand/Cargo.toml +++ b/ndarray-rand/Cargo.toml @@ -14,12 +14,14 @@ keywords = ["multidimensional", "matrix", "rand", "ndarray"] [dependencies] ndarray = { version = "0.12.0", path = ".." } -rand_distr = "0.2.1" [dependencies.rand] version = "0.7.0" features = ["small_rng"] +[dev-dependencies] +rand_distr = "0.2.1" + [package.metadata.release] no-dev-version = true diff --git a/ndarray-rand/src/lib.rs b/ndarray-rand/src/lib.rs index 0fce73886..6e2a4591e 100644 --- a/ndarray-rand/src/lib.rs +++ b/ndarray-rand/src/lib.rs @@ -10,9 +10,9 @@ //! //! See [**`RandomExt`**](trait.RandomExt.html) for usage examples. +use rand::distributions::Distribution; use rand::rngs::SmallRng; use rand::{thread_rng, Rng, SeedableRng}; -use rand_distr::Distribution; use ndarray::ShapeBuilder; use ndarray::{ArrayBase, DataOwned, Dimension}; From 0291f3006720fa250494f7e0507148c999a7135c Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Mon, 22 Jul 2019 13:07:21 -0400 Subject: [PATCH 11/17] bump version, add note to readme --- ndarray-rand/Cargo.toml | 2 +- ndarray-rand/README.rst | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ndarray-rand/Cargo.toml b/ndarray-rand/Cargo.toml index 27e76df17..024174a28 100644 --- a/ndarray-rand/Cargo.toml +++ b/ndarray-rand/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ndarray-rand" -version = "0.9.0" +version = "0.10.0" edition = "2018" authors = ["bluss"] license = "MIT/Apache-2.0" diff --git a/ndarray-rand/README.rst b/ndarray-rand/README.rst index cd7e00225..57f04f7b7 100644 --- a/ndarray-rand/README.rst +++ b/ndarray-rand/README.rst @@ -1,9 +1,25 @@ ndarray-rand ============ +Dependencies +------------ + +ndarray-rand depends on rand 0.7. If you use any other items from rand, +you need to specify a compatible version of rand in your Cargo.toml. If +you want to use a RNG or distribution from another crate with +ndarray-rand, you need to make sure that crate also depends on the +correct version of rand. Otherwise, the compiler will return errors +saying that the items are not compatible (e.g. that a type doesn't +implement a necessary trait). + + Recent Changes -------------- +- 0.10.0 + + - Require rand 0.7 + - 0.9.0 - Require rand 0.6 From b48bb4ab7fc980f846aa2f9fcf6fcc7b3002f0cd Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Mon, 22 Jul 2019 13:21:06 -0400 Subject: [PATCH 12/17] update benches --- ndarray-rand/benches/bench.rs | 4 ++-- ndarray-rand/tests/tests.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ndarray-rand/benches/bench.rs b/ndarray-rand/benches/bench.rs index b356d00e5..52bb236bb 100644 --- a/ndarray-rand/benches/bench.rs +++ b/ndarray-rand/benches/bench.rs @@ -23,11 +23,11 @@ fn uniform_f32(b: &mut Bencher) { #[bench] fn norm_f32(b: &mut Bencher) { let m = 100; - b.iter(|| Array::random((m, m), F32(Normal::new(0., 1.)))); + b.iter(|| Array::random((m, m), F32(Normal::new(0., 1.).unwrap()))); } #[bench] fn norm_f64(b: &mut Bencher) { let m = 100; - b.iter(|| Array::random((m, m), Normal::new(0., 1.))); + b.iter(|| Array::random((m, m), Normal::new(0., 1.).unwrap())); } diff --git a/ndarray-rand/tests/tests.rs b/ndarray-rand/tests/tests.rs index ad248bde3..1f936d25c 100644 --- a/ndarray-rand/tests/tests.rs +++ b/ndarray-rand/tests/tests.rs @@ -1,6 +1,6 @@ use ndarray::Array; use ndarray_rand::RandomExt; -use rand_distr::Uniform; +use rand::distributions::Uniform; #[test] fn test_dim() { From 2b8fe682c216963120bbc3e478cd02e66d6d39fd Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Mon, 22 Jul 2019 13:23:01 -0400 Subject: [PATCH 13/17] fix ndarray-rand edition idioms --- ndarray-rand/benches/bench.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ndarray-rand/benches/bench.rs b/ndarray-rand/benches/bench.rs index 52bb236bb..71faf09fd 100644 --- a/ndarray-rand/benches/bench.rs +++ b/ndarray-rand/benches/bench.rs @@ -1,9 +1,9 @@ #![feature(test)] -extern crate ndarray; -extern crate ndarray_rand; -extern crate rand; -extern crate rand_distr; + + + + extern crate test; use ndarray::Array; From 61884d435fb781406b4647d4ee8886b63392026b Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Mon, 22 Jul 2019 13:25:47 -0400 Subject: [PATCH 14/17] cargo fmt after cargo fix --- ndarray-rand/benches/bench.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ndarray-rand/benches/bench.rs b/ndarray-rand/benches/bench.rs index 71faf09fd..bdd010bc1 100644 --- a/ndarray-rand/benches/bench.rs +++ b/ndarray-rand/benches/bench.rs @@ -1,9 +1,5 @@ #![feature(test)] - - - - extern crate test; use ndarray::Array; From d81407f5fae4948d6cff7628c045be963b2d20b5 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Mon, 22 Jul 2019 22:19:20 -0400 Subject: [PATCH 15/17] note in lib.rs --- ndarray-rand/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ndarray-rand/src/lib.rs b/ndarray-rand/src/lib.rs index 6e2a4591e..b61b5f089 100644 --- a/ndarray-rand/src/lib.rs +++ b/ndarray-rand/src/lib.rs @@ -9,6 +9,15 @@ //! Constructors for randomized arrays. `rand` integration for `ndarray`. //! //! See [**`RandomExt`**](trait.RandomExt.html) for usage examples. +//! +//! Note: ndarray-rand depends on rand 0.7. +//! If you use any other items from rand, you need to +//! specify a compatible version of rand in your Cargo.toml. If +//! you want to use a RNG or distribution from another crate with +//! ndarray-rand, you need to make sure that crate also depends on the +//! correct version of rand. Otherwise, the compiler will return errors +//! saying that the items are not compatible (e.g. that a type doesn't +//! implement a necessary trait). use rand::distributions::Distribution; use rand::rngs::SmallRng; From 0fc704762af8a433e09a6344ec984df49a35a17b Mon Sep 17 00:00:00 2001 From: Jim Turner Date: Tue, 23 Jul 2019 10:48:19 -0400 Subject: [PATCH 16/17] Improve formatting --- ndarray-rand/README.rst | 15 +++++++-------- ndarray-rand/src/lib.rs | 11 +++++------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/ndarray-rand/README.rst b/ndarray-rand/README.rst index 57f04f7b7..41d9ceae3 100644 --- a/ndarray-rand/README.rst +++ b/ndarray-rand/README.rst @@ -4,14 +4,13 @@ ndarray-rand Dependencies ------------ -ndarray-rand depends on rand 0.7. If you use any other items from rand, -you need to specify a compatible version of rand in your Cargo.toml. If -you want to use a RNG or distribution from another crate with -ndarray-rand, you need to make sure that crate also depends on the -correct version of rand. Otherwise, the compiler will return errors -saying that the items are not compatible (e.g. that a type doesn't -implement a necessary trait). - +``ndarray-rand`` depends on ``rand`` 0.7. If you use any other items from +``rand``, you need to specify a compatible version of ``rand`` in your +``Cargo.toml``. If you want to use a RNG or distribution from another crate +with ``ndarray-rand``, you need to make sure that crate also depends on the +correct version of ``rand``. Otherwise, the compiler will return errors saying +that the items are not compatible (e.g. that a type doesn't implement a +necessary trait). Recent Changes -------------- diff --git a/ndarray-rand/src/lib.rs b/ndarray-rand/src/lib.rs index b61b5f089..69d088096 100644 --- a/ndarray-rand/src/lib.rs +++ b/ndarray-rand/src/lib.rs @@ -10,12 +10,11 @@ //! //! See [**`RandomExt`**](trait.RandomExt.html) for usage examples. //! -//! Note: ndarray-rand depends on rand 0.7. -//! If you use any other items from rand, you need to -//! specify a compatible version of rand in your Cargo.toml. If -//! you want to use a RNG or distribution from another crate with -//! ndarray-rand, you need to make sure that crate also depends on the -//! correct version of rand. Otherwise, the compiler will return errors +//! **Note:** `ndarray-rand` depends on `rand` 0.7. If you use any other items +//! from `rand`, you need to specify a compatible version of `rand` in your +//! `Cargo.toml`. If you want to use a RNG or distribution from another crate +//! with `ndarray-rand`, you need to make sure that crate also depends on the +//! correct version of `rand`. Otherwise, the compiler will return errors //! saying that the items are not compatible (e.g. that a type doesn't //! implement a necessary trait). From ec8af57e34371f347bec0c3f450c22f3257fcb11 Mon Sep 17 00:00:00 2001 From: Jim Turner Date: Tue, 23 Jul 2019 10:50:12 -0400 Subject: [PATCH 17/17] Mention Rust 1.32 in ndarray-rand changelog --- ndarray-rand/README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/ndarray-rand/README.rst b/ndarray-rand/README.rst index 41d9ceae3..d764b6cbb 100644 --- a/ndarray-rand/README.rst +++ b/ndarray-rand/README.rst @@ -18,6 +18,7 @@ Recent Changes - 0.10.0 - Require rand 0.7 + - Require Rust 1.32 or later - 0.9.0