diff --git a/.travis.yml b/.travis.yml
index 4ffb25ad7..1115dd728 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,34 +1,50 @@
language: rust
-# use trusty for newer openblas
+
sudo: required
-dist: trusty
+
matrix:
include:
- rust: 1.32.0
- env:
- - FEATURES='test docs'
- - RUSTFLAGS='-D warnings'
+ env: FEATURES="blas serde-1 docs"
- rust: stable
- env:
- - FEATURES='test docs'
- - RUSTFLAGS='-D warnings'
+ env: FEATURES="blas serde-1 docs"
- rust: beta
- env:
- - FEATURES='test docs'
- - CHANNEL='beta'
- - RUSTFLAGS='-D warnings'
+ env: FEATURES="blas serde-1 docs"
- rust: nightly
- env:
- - FEATURES='test docs'
- - CHANNEL='nightly'
+ env: FEATURES="blas serde-1 docs nightly"
+ allow_failures:
+ - rust: beta
+ - rust: nightly
+
env:
global:
- - HOST=x86_64-unknown-linux-gnu
- - CARGO_INCREMENTAL=0
+ - RUSTFLAGS="-D warnings"
+
+cache: cargo
+
addons:
apt:
+ update: true
packages:
- libopenblas-dev
- gfortran
+ # kcov dependencies
+ - cmake
+ - g++
+ - pkg-config
+ - jq
+ - libcurl4-openssl-dev
+ - libelf-dev
+ - libdw-dev
+ - binutils-dev
+ - libiberty-dev
+
+
+before_script:
+ - ./ci/before_script.sh
+
script:
- - ./scripts/all-tests.sh "$FEATURES" "$CHANNEL"
+ - ./ci/script.sh
+
+after_success:
+ - ./ci/after_success.sh
diff --git a/Cargo.toml b/Cargo.toml
index e9ea56d8c..855d16c93 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -28,29 +28,25 @@ bench = false
test = true
[dependencies]
+itertools = { version = "0.8.0", default-features = false }
+matrixmultiply = "0.2.0"
+num-complex = "0.2"
num-integer = "0.1.39"
num-traits = "0.2"
-num-complex = "0.2"
-itertools = { version = "0.8.0", default-features = false }
-
-rayon = { version = "1.0.3", optional = true }
+## Optional dependencies
approx = { version = "0.3.2", optional = true }
-
-# Use via the `blas` crate feature!
-cblas-sys = { version = "0.1.4", optional = true, default-features = false }
blas-src = { version = "0.2.0", optional = true, default-features = false }
-
-matrixmultiply = { version = "0.2.0" }
-# Use via the `serde-1` crate feature!
+cblas-sys = { version = "0.1.4", optional = true, default-features = false }
serde = { version = "1.0", optional = true }
+rayon = { version = "1.0.3", optional = true }
[dev-dependencies]
+approx = "0.3.2"
defmac = "0.2"
+itertools = { version = "0.8.0", default-features = false, features = ["use_std"] }
quickcheck = { version = "0.8", default-features = false }
rawpointer = "0.1"
-approx = "0.3.2"
-itertools = { version = "0.8.0", default-features = false, features = ["use_std"] }
[features]
# Enable blas usage
@@ -60,9 +56,8 @@ blas = ["cblas-sys", "blas-src"]
# Serde 1.0
serde-1 = ["serde"]
-# These features are used for testing
-test-blas-openblas-sys = ["blas"]
-test = ["test-blas-openblas-sys"]
+# Enable nightly-only features
+nightly = []
# This feature is used for docs
docs = ["approx", "serde-1", "rayon"]
diff --git a/benches/bench1.rs b/benches/bench1.rs
index 4f44f555c..1f20a5b74 100644
--- a/benches/bench1.rs
+++ b/benches/bench1.rs
@@ -1,3 +1,4 @@
+#![cfg(feature = "nightly")]
#![feature(test)]
#![allow(unused_imports)]
#![allow(
diff --git a/benches/chunks.rs b/benches/chunks.rs
index a60a6b1fe..30785d855 100644
--- a/benches/chunks.rs
+++ b/benches/chunks.rs
@@ -1,3 +1,4 @@
+#![cfg(feature = "nightly")]
#![feature(test)]
extern crate test;
diff --git a/benches/construct.rs b/benches/construct.rs
index 3d77a89e0..2ef7a3613 100644
--- a/benches/construct.rs
+++ b/benches/construct.rs
@@ -1,3 +1,4 @@
+#![cfg(feature = "nightly")]
#![feature(test)]
#![allow(
clippy::many_single_char_names,
diff --git a/benches/gemv.rs b/benches/gemv.rs
index 4bca08319..e21addec9 100644
--- a/benches/gemv.rs
+++ b/benches/gemv.rs
@@ -1,3 +1,4 @@
+#![cfg(feature = "nightly")]
#![feature(test)]
#![allow(
clippy::many_single_char_names,
diff --git a/benches/higher-order.rs b/benches/higher-order.rs
index 2ea0721af..67094c9fe 100644
--- a/benches/higher-order.rs
+++ b/benches/higher-order.rs
@@ -1,3 +1,4 @@
+#![cfg(feature = "nightly")]
#![feature(test)]
#![allow(
clippy::many_single_char_names,
diff --git a/benches/iter.rs b/benches/iter.rs
index 5cc04293f..4d1d7ea4b 100644
--- a/benches/iter.rs
+++ b/benches/iter.rs
@@ -1,3 +1,4 @@
+#![cfg(feature = "nightly")]
#![feature(test)]
#![allow(
clippy::many_single_char_names,
diff --git a/benches/numeric.rs b/benches/numeric.rs
index 4c579eb71..a2b5bb832 100644
--- a/benches/numeric.rs
+++ b/benches/numeric.rs
@@ -1,3 +1,4 @@
+#![cfg(feature = "nightly")]
#![feature(test)]
extern crate test;
diff --git a/benches/par_rayon.rs b/benches/par_rayon.rs
index 55fed98e0..343f772ec 100644
--- a/benches/par_rayon.rs
+++ b/benches/par_rayon.rs
@@ -1,3 +1,4 @@
+#![cfg(feature = "nightly")]
#![cfg(feature = "rayon")]
#![feature(test)]
diff --git a/build.rs b/build.rs
index ceeeff389..ffb3fbee5 100644
--- a/build.rs
+++ b/build.rs
@@ -1,10 +1,8 @@
-///
-/// This build script emits the openblas linking directive if requested
-///
+//! This build script emits the openblas linking directive if requested
fn main() {
println!("cargo:rerun-if-changed=build.rs");
- if cfg!(feature = "test-blas-openblas-sys") {
+ if cfg!(feature = "blas") {
println!("cargo:rustc-link-lib={}=openblas", "dylib");
}
}
diff --git a/ci/after_success.sh b/ci/after_success.sh
new file mode 100755
index 000000000..ad368efee
--- /dev/null
+++ b/ci/after_success.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+# Echo all commands before executing them
+set -o xtrace
+# Forbid any unset variables
+set -o nounset
+# Exit on any error
+set -o errexit
+
+
+run_kcov() {
+ sh <(cargo kcov --print-install-kcov-sh)
+ KCOV_BIN="./$(ls | grep kcov)/build/src/kcov"
+
+ # Run kcov on all the test suites
+ cargo kcov --all --no-default-features --output kcov-no-default-features
+ cargo kcov --all --features "$FEATURES" --output kcov-features
+
+ $KCOV_BIN --merge kcov \
+ kcov-no-default-features \
+ kcov-features
+}
+
+coverage_codecov() {
+ if [[ "$TRAVIS_RUST_VERSION" != "stable" ]]; then
+ return
+ fi
+
+ run_kcov
+
+ bash <(curl -s https://codecov.io/bash) -s kcov
+ echo "Uploaded code coverage to codecov.io"
+}
+
+main() {
+ coverage_codecov
+}
+
+main
diff --git a/ci/before_script.sh b/ci/before_script.sh
new file mode 100755
index 000000000..d9e9c9e3a
--- /dev/null
+++ b/ci/before_script.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# Echo all commands before executing them
+set -o xtrace
+# Forbid any unset variables
+set -o nounset
+# Exit on any error
+set -o errexit
+
+# Install clippy and rustfmt
+rustup_tools() {
+ rustup component add clippy rustfmt
+}
+
+# Install cargo tools
+cargo_tools() {
+ if [[ "$TRAVIS_RUST_VERSION" != "stable" ]]; then
+ return
+ fi
+ cargo install cargo-update || echo "cargo-update already installed"
+ cargo install cargo-kcov || echo "cargo-kcov already installed"
+ # Update cached binaries
+ cargo install-update -a
+}
+
+main() {
+ rustup_tools
+ cargo_tools
+}
+
+main
diff --git a/ci/script.sh b/ci/script.sh
new file mode 100755
index 000000000..911e97608
--- /dev/null
+++ b/ci/script.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# Echo all commands before executing them
+set -o xtrace
+# Forbid any unset variables
+set -o nounset
+# Exit on any error
+set -o errexit
+
+# Ensure there are no outstanding lints.
+check_lints() {
+ ## In the future, it would be good if `|| true` can be removed so that
+ ## clippy warnings abort the build.
+ cargo clippy --all --features "$FEATURES" || true
+}
+
+# Ensure the code is correctly formatted.
+check_format() {
+ cargo fmt --all -- --check
+}
+
+# Run the test suite.
+check_tests() {
+ cargo test --all --no-default-features
+ cargo test --all --features "$FEATURES"
+}
+
+main() {
+ check_lints
+ check_format
+ check_tests
+}
+
+main
diff --git a/ndarray-rand/benches/bench.rs b/ndarray-rand/benches/bench.rs
index bdd010bc1..7bac53b05 100644
--- a/ndarray-rand/benches/bench.rs
+++ b/ndarray-rand/benches/bench.rs
@@ -1,3 +1,4 @@
+#![cfg(feature = "nightly")]
#![feature(test)]
extern crate test;
diff --git a/numeric-tests/Cargo.toml b/numeric-tests/Cargo.toml
index dc1261512..96afc7a05 100644
--- a/numeric-tests/Cargo.toml
+++ b/numeric-tests/Cargo.toml
@@ -18,9 +18,4 @@ features = ["small_rng"]
test = false
[features]
-test_blas = ["ndarray/blas", "ndarray/test-blas-openblas-sys"]
-
-[profile.dev]
-opt-level = 2
-[profile.test]
-opt-level = 2
+test_blas = ["ndarray/blas"]
\ No newline at end of file
diff --git a/parallel/Cargo.toml b/parallel/Cargo.toml
index 9eb8e231e..21986684f 100644
--- a/parallel/Cargo.toml
+++ b/parallel/Cargo.toml
@@ -13,10 +13,11 @@ keywords = ["data-structure", "multidimensional", "parallel", "concurrent"]
categories = ["data-structures", "science", "concurrency"]
[dependencies]
-rayon = { version = "1.0" }
-ndarray = { version = "0.12.0", path = "../" }
+rayon = "1.0"
+ndarray = { version = "0.12.0", path = "../", features = ["rayon"]}
[dev-dependencies]
+approx = "0.3.2"
num_cpus = "1.2"
itertools = { version = "0.8.0", default-features = false }
diff --git a/parallel/benches/rayon.rs b/parallel/benches/rayon.rs
index 629cb21c4..fe396029f 100644
--- a/parallel/benches/rayon.rs
+++ b/parallel/benches/rayon.rs
@@ -1,3 +1,4 @@
+#![cfg(feature = "nightly")]
#![feature(test)]
extern crate num_cpus;
diff --git a/parallel/src/into_impls.rs b/parallel/src/into_impls.rs
index 9ac578d2e..dea5c7b4b 100644
--- a/parallel/src/into_impls.rs
+++ b/parallel/src/into_impls.rs
@@ -1,4 +1,4 @@
-use ndarray::{Array, ArrayView, ArrayViewMut, Dimension, RcArray};
+use ndarray::{ArcArray, Array, ArrayView, ArrayViewMut, Dimension};
use NdarrayIntoParallelIterator;
use Parallel;
@@ -16,7 +16,7 @@ where
}
// This is allowed: goes through `.view()`
-impl<'a, A, D> NdarrayIntoParallelIterator for &'a RcArray
+impl<'a, A, D> NdarrayIntoParallelIterator for &'a ArcArray
where
D: Dimension,
A: Sync,
@@ -41,7 +41,7 @@ where
}
// This is allowed: goes through `.view_mut()`, which is unique access
-impl<'a, A, D> NdarrayIntoParallelIterator for &'a mut RcArray
+impl<'a, A, D> NdarrayIntoParallelIterator for &'a mut ArcArray
where
D: Dimension,
A: Sync + Send + Clone,
diff --git a/parallel/tests/azip.rs b/parallel/tests/azip.rs
index 487552596..8d088c8f1 100644
--- a/parallel/tests/azip.rs
+++ b/parallel/tests/azip.rs
@@ -1,7 +1,9 @@
+extern crate approx;
extern crate itertools;
extern crate ndarray;
extern crate ndarray_parallel;
+use approx::assert_abs_diff_eq;
use itertools::enumerate;
use ndarray::prelude::*;
use ndarray_parallel::par_azip;
@@ -37,7 +39,7 @@ fn test_par_azip3() {
*c = a.sin();
});
let res = Array::linspace(0., 3.1, 32).mapv_into(f32::sin);
- assert!(res.all_close(&ArrayView::from(&c), 1e-4));
+ assert_abs_diff_eq!(res, ArrayView::from(&c), epsilon = 1e-4);
}
#[should_panic]
diff --git a/parallel/tests/rayon.rs b/parallel/tests/rayon.rs
index 9432f9edf..98e03a6c7 100644
--- a/parallel/tests/rayon.rs
+++ b/parallel/tests/rayon.rs
@@ -1,7 +1,9 @@
+extern crate approx;
extern crate ndarray;
extern crate ndarray_parallel;
extern crate rayon;
+use approx::assert_abs_diff_eq;
use ndarray::prelude::*;
use ndarray_parallel::prelude::*;
@@ -30,7 +32,7 @@ fn test_axis_iter_mut() {
.into_par_iter()
.for_each(|mut v| v.mapv_inplace(|x| x.exp()));
println!("{:?}", a.slice(s![..10, ..5]));
- assert!(a.all_close(&b, 0.001));
+ assert_abs_diff_eq!(a, b, epsilon = 1e-3);
}
#[test]
diff --git a/parallel/tests/zip.rs b/parallel/tests/zip.rs
index 63cdd5e92..8eb98d6fc 100644
--- a/parallel/tests/zip.rs
+++ b/parallel/tests/zip.rs
@@ -2,8 +2,6 @@ extern crate ndarray;
extern crate ndarray_parallel;
use ndarray::prelude::*;
-use ndarray_parallel::prelude::*;
-
use ndarray::Zip;
const M: usize = 1024 * 10;
diff --git a/serialization-tests/Cargo.toml b/serialization-tests/Cargo.toml
index 9c46600e1..5e56a2675 100644
--- a/serialization-tests/Cargo.toml
+++ b/serialization-tests/Cargo.toml
@@ -9,19 +9,12 @@ test = false
[dependencies]
ndarray = { path = "../", features = ["serde-1"] }
+ron = { version = "0.1.1", optional = true }
[features]
default = ["ron"]
-[dev-dependencies.serde]
-version = "1.0"
-
-[dev-dependencies.serde_json]
-version = "1.0"
-
-[dev-dependencies.rmp-serde]
-version = "0.13.1"
-
-[dependencies.ron]
-version = "0.1.1"
-optional = true
+[dev-dependencies]
+serde = "1.0"
+serde_json = "1.0"
+rmp-serde = "0.13.1"
\ No newline at end of file
diff --git a/serialization-tests/tests/serialize.rs b/serialization-tests/tests/serialize.rs
index 953f2a434..0d35aabf6 100644
--- a/serialization-tests/tests/serialize.rs
+++ b/serialization-tests/tests/serialize.rs
@@ -1,11 +1,8 @@
extern crate ndarray;
-
+extern crate rmp_serde;
extern crate serde;
-
extern crate serde_json;
-extern crate rmp_serde;
-
#[cfg(feature = "ron")]
extern crate ron;