Skip to content

Commit

Permalink
Merge branch 'master' into fix-axis-iter
Browse files Browse the repository at this point in the history
  • Loading branch information
jturner314 committed Aug 20, 2019
2 parents 4f857a3 + ce80d38 commit 1443df8
Show file tree
Hide file tree
Showing 70 changed files with 225 additions and 272 deletions.
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ sudo: required
dist: trusty
matrix:
include:
- rust: 1.31.0
- rust: 1.32.0
env:
- FEATURES='test docs'
- RUSTFLAGS='-D warnings'
- rust: stable
env:
- FEATURES='test docs'
- RUSTFLAGS='-D warnings'
- rust: beta
env:
- FEATURES='test docs'
- CHANNEL='beta'
- RUSTFLAGS='-D warnings'
- rust: nightly
env:
- FEATURES='test docs'
Expand All @@ -27,9 +30,5 @@ addons:
packages:
- libopenblas-dev
- gfortran
before_script:
- rustup component add rustfmt
script:
- |
cargo fmt --all -- --check &&
./scripts/all-tests.sh "$FEATURES" "$CHANNEL"
- ./scripts/all-tests.sh "$FEATURES" "$CHANNEL"
1 change: 0 additions & 1 deletion benches/bench1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
clippy::many_single_char_names
)]

extern crate ndarray;
extern crate test;

use ndarray::ShapeBuilder;
Expand Down
1 change: 0 additions & 1 deletion benches/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
extern crate test;
use test::Bencher;

extern crate ndarray;
use ndarray::prelude::*;
use ndarray::NdProducer;

Expand Down
1 change: 0 additions & 1 deletion benches/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
extern crate test;
use test::Bencher;

extern crate ndarray;
use ndarray::prelude::*;

#[bench]
Expand Down
1 change: 0 additions & 1 deletion benches/gemv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
extern crate test;
use test::Bencher;

extern crate ndarray;
use ndarray::prelude::*;

use ndarray::linalg::general_mat_vec_mul;
Expand Down
3 changes: 1 addition & 2 deletions benches/higher-order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::iter::FromIterator;
use test::black_box;
use test::Bencher;

extern crate ndarray;
use ndarray::prelude::*;

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

pub fn double_array(mut a: ArrayViewMut2<f64>) {
pub fn double_array(mut a: ArrayViewMut2<'_, f64>) {
a *= 2.0;
}

Expand Down
2 changes: 0 additions & 2 deletions benches/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
clippy::many_single_char_names
)]

extern crate rawpointer;
extern crate test;
use rawpointer::PointerExt;
use test::black_box;
use test::Bencher;

extern crate ndarray;
use ndarray::prelude::*;
use ndarray::Slice;
use ndarray::{FoldWhile, Zip};
Expand Down
1 change: 0 additions & 1 deletion benches/numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
extern crate test;
use test::Bencher;

extern crate ndarray;
use ndarray::prelude::*;

const N: usize = 1024;
Expand Down
7 changes: 0 additions & 7 deletions benches/par_rayon.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#![cfg(feature = "rayon")]
#![feature(test)]

extern crate rayon;

extern crate itertools;
extern crate ndarray;

use ndarray::parallel::prelude::*;
use ndarray::prelude::*;

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

use std::cmp::max;

fn set_threads() {
// Consider setting a fixed number of threads here, for example to avoid
// oversubscribing on hyperthreaded cores.
Expand Down
1 change: 0 additions & 1 deletion examples/axis_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
clippy::unreadable_literal,
clippy::many_single_char_names
)]
extern crate ndarray;

use ndarray::prelude::*;

Expand Down
2 changes: 0 additions & 2 deletions examples/bounds_check_elim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

// Test cases for bounds check elimination

extern crate ndarray;

use ndarray::prelude::*;

/*
Expand Down
4 changes: 1 addition & 3 deletions examples/column_standardize.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
extern crate ndarray;

use ndarray::prelude::*;

fn std1d(a: ArrayView1<f64>) -> f64 {
fn std1d(a: ArrayView1<'_, f64>) -> f64 {
let n = a.len() as f64;
if n == 0. {
return 0.;
Expand Down
2 changes: 1 addition & 1 deletion examples/convo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const SHARPEN: [[f32; 3]; 3] = [[0., -1., 0.], [-1., 5., -1.], [0., -1., 0.]];
type Kernel3x3<A> = [[A; 3]; 3];

#[inline(never)]
fn conv_3x3<F>(a: &ArrayView2<F>, out: &mut ArrayViewMut2<F>, kernel: &Kernel3x3<F>)
fn conv_3x3<F>(a: &ArrayView2<'_, F>, out: &mut ArrayViewMut2<'_, F>, kernel: &Kernel3x3<F>)
where
F: Float,
{
Expand Down
3 changes: 1 addition & 2 deletions examples/life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
clippy::unreadable_literal,
clippy::many_single_char_names
)]
extern crate ndarray;

use ndarray::prelude::*;
use std::iter::FromIterator;

const INPUT: &'static [u8] = include_bytes!("life.txt");
const INPUT: &[u8] = include_bytes!("life.txt");

const N: usize = 100;

Expand Down
2 changes: 0 additions & 2 deletions examples/rollaxis.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate ndarray;

use ndarray::prelude::*;
use ndarray::Data;

Expand Down
2 changes: 0 additions & 2 deletions examples/sort-axis.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate ndarray;

use ndarray::prelude::*;
use ndarray::{Data, RemoveAxis, Zip};

Expand Down
1 change: 0 additions & 1 deletion examples/zip_many.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
clippy::unreadable_literal,
clippy::many_single_char_names
)]
extern crate ndarray;

use ndarray::prelude::*;
use ndarray::Zip;
Expand Down
10 changes: 8 additions & 2 deletions ndarray-rand/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -13,9 +13,15 @@ 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"]

[dev-dependencies]
rand_distr = "0.2.1"

[package.metadata.release]
no-dev-version = true

16 changes: 16 additions & 0 deletions ndarray-rand/README.rst
Original file line number Diff line number Diff line change
@@ -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
- Require Rust 1.32 or later

- 0.9.0

- Require rand 0.6
Expand Down
22 changes: 5 additions & 17 deletions ndarray-rand/benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,29 @@
#![feature(test)]

extern crate ndarray;
extern crate ndarray_rand;
extern crate rand;
extern crate test;

use ndarray::Array;
use ndarray_rand::RandomExt;
use ndarray_rand::F32;
use rand::distributions::Normal;
use rand::distributions::Uniform;
use rand_distr::Normal;
use rand_distr::Uniform;

use test::Bencher;

#[bench]
fn uniform_f32(b: &mut Bencher) {
let m = 100;
b.iter(|| {
let a = Array::random((m, m), Uniform::new(-1f32, 1.));
a
});
b.iter(|| Array::random((m, m), Uniform::new(-1f32, 1.)));
}

#[bench]
fn norm_f32(b: &mut Bencher) {
let m = 100;
b.iter(|| {
let a = Array::random((m, m), F32(Normal::new(0., 1.)));
a
});
b.iter(|| Array::random((m, m), F32(Normal::new(0., 1.).unwrap())));
}

#[bench]
fn norm_f64(b: &mut Bencher) {
let m = 100;
b.iter(|| {
let a = Array::random((m, m), Normal::new(0., 1.));
a
});
b.iter(|| Array::random((m, m), Normal::new(0., 1.).unwrap()));
}
8 changes: 8 additions & 0 deletions ndarray-rand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
//! 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;
Expand Down
6 changes: 5 additions & 1 deletion numeric-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions numeric-tests/tests/accuracy.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand All @@ -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};

Expand Down Expand Up @@ -52,12 +53,12 @@ fn reference_mat_mul<A, S, S2>(lhs: &ArrayBase<S, Ix2>, rhs: &ArrayBase<S2, Ix2>
fn gen<D>(d: D) -> Array<f32, D>
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: D) -> Array<f64, D>
where D: Dimension,
{
Array::random(d, Normal::new(0., 1.))
Array::random(d, Normal::new(0., 1.).unwrap())
}

#[test]
Expand Down
1 change: 1 addition & 0 deletions scripts/all-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -e
FEATURES=$1
CHANNEL=$2

([ "$CHANNEL" != "beta" ] || (rustup component add rustfmt && cargo fmt --all -- --check))
cargo build --verbose --no-default-features
cargo test --verbose --no-default-features
cargo test --release --verbose --no-default-features
Expand Down
Loading

0 comments on commit 1443df8

Please sign in to comment.