Skip to content

Commit 1443df8

Browse files
committed
Merge branch 'master' into fix-axis-iter
2 parents 4f857a3 + ce80d38 commit 1443df8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+225
-272
lines changed

.travis.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@ sudo: required
44
dist: trusty
55
matrix:
66
include:
7-
- rust: 1.31.0
7+
- rust: 1.32.0
88
env:
99
- FEATURES='test docs'
10+
- RUSTFLAGS='-D warnings'
1011
- rust: stable
1112
env:
1213
- FEATURES='test docs'
14+
- RUSTFLAGS='-D warnings'
1315
- rust: beta
1416
env:
1517
- FEATURES='test docs'
1618
- CHANNEL='beta'
19+
- RUSTFLAGS='-D warnings'
1720
- rust: nightly
1821
env:
1922
- FEATURES='test docs'
@@ -27,9 +30,5 @@ addons:
2730
packages:
2831
- libopenblas-dev
2932
- gfortran
30-
before_script:
31-
- rustup component add rustfmt
3233
script:
33-
- |
34-
cargo fmt --all -- --check &&
35-
./scripts/all-tests.sh "$FEATURES" "$CHANNEL"
34+
- ./scripts/all-tests.sh "$FEATURES" "$CHANNEL"

benches/bench1.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
clippy::many_single_char_names
88
)]
99

10-
extern crate ndarray;
1110
extern crate test;
1211

1312
use ndarray::ShapeBuilder;

benches/chunks.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
extern crate test;
44
use test::Bencher;
55

6-
extern crate ndarray;
76
use ndarray::prelude::*;
87
use ndarray::NdProducer;
98

benches/construct.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
extern crate test;
99
use test::Bencher;
1010

11-
extern crate ndarray;
1211
use ndarray::prelude::*;
1312

1413
#[bench]

benches/gemv.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
extern crate test;
1010
use test::Bencher;
1111

12-
extern crate ndarray;
1312
use ndarray::prelude::*;
1413

1514
use ndarray::linalg::general_mat_vec_mul;

benches/higher-order.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use std::iter::FromIterator;
1010
use test::black_box;
1111
use test::Bencher;
1212

13-
extern crate ndarray;
1413
use ndarray::prelude::*;
1514

1615
const N: usize = 1024;
@@ -23,7 +22,7 @@ fn map_regular(bench: &mut Bencher) {
2322
bench.iter(|| a.map(|&x| 2. * x));
2423
}
2524

26-
pub fn double_array(mut a: ArrayViewMut2<f64>) {
25+
pub fn double_array(mut a: ArrayViewMut2<'_, f64>) {
2726
a *= 2.0;
2827
}
2928

benches/iter.rs

-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
clippy::many_single_char_names
77
)]
88

9-
extern crate rawpointer;
109
extern crate test;
1110
use rawpointer::PointerExt;
1211
use test::black_box;
1312
use test::Bencher;
1413

15-
extern crate ndarray;
1614
use ndarray::prelude::*;
1715
use ndarray::Slice;
1816
use ndarray::{FoldWhile, Zip};

benches/numeric.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
extern crate test;
44
use test::Bencher;
55

6-
extern crate ndarray;
76
use ndarray::prelude::*;
87

98
const N: usize = 1024;

benches/par_rayon.rs

-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
#![cfg(feature = "rayon")]
22
#![feature(test)]
33

4-
extern crate rayon;
5-
6-
extern crate itertools;
7-
extern crate ndarray;
8-
94
use ndarray::parallel::prelude::*;
105
use ndarray::prelude::*;
116

@@ -17,8 +12,6 @@ use ndarray::Zip;
1712
const EXP_N: usize = 256;
1813
const ADDN: usize = 512;
1914

20-
use std::cmp::max;
21-
2215
fn set_threads() {
2316
// Consider setting a fixed number of threads here, for example to avoid
2417
// oversubscribing on hyperthreaded cores.

examples/axis_ops.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
clippy::unreadable_literal,
55
clippy::many_single_char_names
66
)]
7-
extern crate ndarray;
87

98
use ndarray::prelude::*;
109

examples/bounds_check_elim.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
// Test cases for bounds check elimination
1010

11-
extern crate ndarray;
12-
1311
use ndarray::prelude::*;
1412

1513
/*

examples/column_standardize.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
extern crate ndarray;
2-
31
use ndarray::prelude::*;
42

5-
fn std1d(a: ArrayView1<f64>) -> f64 {
3+
fn std1d(a: ArrayView1<'_, f64>) -> f64 {
64
let n = a.len() as f64;
75
if n == 0. {
86
return 0.;

examples/convo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const SHARPEN: [[f32; 3]; 3] = [[0., -1., 0.], [-1., 5., -1.], [0., -1., 0.]];
1313
type Kernel3x3<A> = [[A; 3]; 3];
1414

1515
#[inline(never)]
16-
fn conv_3x3<F>(a: &ArrayView2<F>, out: &mut ArrayViewMut2<F>, kernel: &Kernel3x3<F>)
16+
fn conv_3x3<F>(a: &ArrayView2<'_, F>, out: &mut ArrayViewMut2<'_, F>, kernel: &Kernel3x3<F>)
1717
where
1818
F: Float,
1919
{

examples/life.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
clippy::unreadable_literal,
55
clippy::many_single_char_names
66
)]
7-
extern crate ndarray;
87

98
use ndarray::prelude::*;
109
use std::iter::FromIterator;
1110

12-
const INPUT: &'static [u8] = include_bytes!("life.txt");
11+
const INPUT: &[u8] = include_bytes!("life.txt");
1312

1413
const N: usize = 100;
1514

examples/rollaxis.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
extern crate ndarray;
2-
31
use ndarray::prelude::*;
42
use ndarray::Data;
53

examples/sort-axis.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
extern crate ndarray;
2-
31
use ndarray::prelude::*;
42
use ndarray::{Data, RemoveAxis, Zip};
53

examples/zip_many.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
clippy::unreadable_literal,
55
clippy::many_single_char_names
66
)]
7-
extern crate ndarray;
87

98
use ndarray::prelude::*;
109
use ndarray::Zip;

ndarray-rand/Cargo.toml

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ndarray-rand"
3-
version = "0.9.0"
3+
version = "0.10.0"
44
edition = "2018"
55
authors = ["bluss"]
66
license = "MIT/Apache-2.0"
@@ -13,9 +13,15 @@ description = "Constructors for randomized arrays. `rand` integration for `ndarr
1313
keywords = ["multidimensional", "matrix", "rand", "ndarray"]
1414

1515
[dependencies]
16-
rand = "0.6.0"
1716
ndarray = { version = "0.12.0", path = ".." }
1817

18+
[dependencies.rand]
19+
version = "0.7.0"
20+
features = ["small_rng"]
21+
22+
[dev-dependencies]
23+
rand_distr = "0.2.1"
24+
1925
[package.metadata.release]
2026
no-dev-version = true
2127

ndarray-rand/README.rst

+16
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
ndarray-rand
22
============
33

4+
Dependencies
5+
------------
6+
7+
``ndarray-rand`` depends on ``rand`` 0.7. If you use any other items from
8+
``rand``, you need to specify a compatible version of ``rand`` in your
9+
``Cargo.toml``. If you want to use a RNG or distribution from another crate
10+
with ``ndarray-rand``, you need to make sure that crate also depends on the
11+
correct version of ``rand``. Otherwise, the compiler will return errors saying
12+
that the items are not compatible (e.g. that a type doesn't implement a
13+
necessary trait).
14+
415
Recent Changes
516
--------------
617

18+
- 0.10.0
19+
20+
- Require rand 0.7
21+
- Require Rust 1.32 or later
22+
723
- 0.9.0
824

925
- Require rand 0.6

ndarray-rand/benches/bench.rs

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,29 @@
11
#![feature(test)]
22

3-
extern crate ndarray;
4-
extern crate ndarray_rand;
5-
extern crate rand;
63
extern crate test;
74

85
use ndarray::Array;
96
use ndarray_rand::RandomExt;
107
use ndarray_rand::F32;
11-
use rand::distributions::Normal;
12-
use rand::distributions::Uniform;
8+
use rand_distr::Normal;
9+
use rand_distr::Uniform;
1310

1411
use test::Bencher;
1512

1613
#[bench]
1714
fn uniform_f32(b: &mut Bencher) {
1815
let m = 100;
19-
b.iter(|| {
20-
let a = Array::random((m, m), Uniform::new(-1f32, 1.));
21-
a
22-
});
16+
b.iter(|| Array::random((m, m), Uniform::new(-1f32, 1.)));
2317
}
2418

2519
#[bench]
2620
fn norm_f32(b: &mut Bencher) {
2721
let m = 100;
28-
b.iter(|| {
29-
let a = Array::random((m, m), F32(Normal::new(0., 1.)));
30-
a
31-
});
22+
b.iter(|| Array::random((m, m), F32(Normal::new(0., 1.).unwrap())));
3223
}
3324

3425
#[bench]
3526
fn norm_f64(b: &mut Bencher) {
3627
let m = 100;
37-
b.iter(|| {
38-
let a = Array::random((m, m), Normal::new(0., 1.));
39-
a
40-
});
28+
b.iter(|| Array::random((m, m), Normal::new(0., 1.).unwrap()));
4129
}

ndarray-rand/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
//! Constructors for randomized arrays. `rand` integration for `ndarray`.
1010
//!
1111
//! See [**`RandomExt`**](trait.RandomExt.html) for usage examples.
12+
//!
13+
//! **Note:** `ndarray-rand` depends on `rand` 0.7. If you use any other items
14+
//! from `rand`, you need to specify a compatible version of `rand` in your
15+
//! `Cargo.toml`. If you want to use a RNG or distribution from another crate
16+
//! with `ndarray-rand`, you need to make sure that crate also depends on the
17+
//! correct version of `rand`. Otherwise, the compiler will return errors
18+
//! saying that the items are not compatible (e.g. that a type doesn't
19+
//! implement a necessary trait).
1220
1321
use rand::distributions::Distribution;
1422
use rand::rngs::SmallRng;

numeric-tests/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ publish = false
88
approx = "0.3.2"
99
ndarray = { path = "..", features = ["approx"] }
1010
ndarray-rand = { path = "../ndarray-rand/" }
11-
rand = "0.6.0"
11+
rand_distr = "0.2.1"
12+
13+
[dependencies.rand]
14+
version = "0.7.0"
15+
features = ["small_rng"]
1216

1317
[lib]
1418
test = false

numeric-tests/tests/accuracy.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
extern crate approx;
2+
extern crate rand_distr;
23
extern crate ndarray;
34
extern crate ndarray_rand;
45
extern crate rand;
56

67
use ndarray_rand::{RandomExt, F32};
7-
use rand::{FromEntropy, Rng};
8+
use rand::{Rng, SeedableRng};
89
use rand::rngs::SmallRng;
910

1011
use ndarray::prelude::*;
@@ -14,7 +15,7 @@ use ndarray::{
1415
};
1516
use ndarray::linalg::general_mat_mul;
1617

17-
use rand::distributions::Normal;
18+
use rand_distr::Normal;
1819

1920
use approx::{assert_abs_diff_eq, assert_relative_eq};
2021

@@ -52,12 +53,12 @@ fn reference_mat_mul<A, S, S2>(lhs: &ArrayBase<S, Ix2>, rhs: &ArrayBase<S2, Ix2>
5253
fn gen<D>(d: D) -> Array<f32, D>
5354
where D: Dimension,
5455
{
55-
Array::random(d, F32(Normal::new(0., 1.)))
56+
Array::random(d, F32(Normal::new(0., 1.).unwrap()))
5657
}
5758
fn gen_f64<D>(d: D) -> Array<f64, D>
5859
where D: Dimension,
5960
{
60-
Array::random(d, Normal::new(0., 1.))
61+
Array::random(d, Normal::new(0., 1.).unwrap())
6162
}
6263

6364
#[test]

scripts/all-tests.sh

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set -e
66
FEATURES=$1
77
CHANNEL=$2
88

9+
([ "$CHANNEL" != "beta" ] || (rustup component add rustfmt && cargo fmt --all -- --check))
910
cargo build --verbose --no-default-features
1011
cargo test --verbose --no-default-features
1112
cargo test --release --verbose --no-default-features

0 commit comments

Comments
 (0)