Repository: statrs-dev/statrs (language: rust)

Issue:
Update to rand >= 0.8
Currently, `statrs` relies on `rand` 0.7 and `nalgebra` 0.23 (which itself relies on `rand` 0.7).  The newer releases of `nalgebra` update their dependency to the latest `rand`, which is currently 0.8.3.  One of the minor, but frustrating, differences between 0.7 and 0.8 is a change in the syntax of the `rand_range` function, from taking 2 arguments to taking a single range argument.

It would be great if `statrs` could be updated to rely on a newer `nalgebra` and a newer `statrs`.  Currently, if one is depending on `rand` >= 0.8 (or is depending on any package that depends on this), then multiple different versions of `rand` are pulled down.  Not only does this bloat the build, but it can run the risk of confusing the compiler about definitions that appear in both versions of the package.

The actual changes to conform with the new API interface of `rnd_range` are small, but I think there are some other changes that would need to be made, since the version of `nalgebra` should be bumped (but perhaps not to the very latest (0.26.1), unless other changes are made because they have deprecated some interfaces that are currently used in `statrs`).  


Discussion / hints:
> but it can run the risk of confusing the compiler about definitions that appear in both versions of the package.

I don't think this can happen. There are some crates for which you can only link to one version, but `rand` is not one of them.

Fix patch:
diff --git a/.travis.yml b/.travis.yml
index c140f8c6..4483b13f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -33,7 +33,12 @@ before_script:
 script:
   - cargo fmt --all -- --check
   - cargo build
-  - cargo test
+  - >
+    if [[ "$TRAVIS_RUST_VERSION" == "nightly" ]]; then
+      cargo test --features nightly
+    else
+      cargo test
+    fi
 
 after_success: >
   if [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$TRAVIS_RUST_VERSION" == "stable" ]]; then
diff --git a/Cargo.toml b/Cargo.toml
index a71228cf..83699ea7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,13 +13,15 @@ repository = "https://github.com/boxtown/statrs"
 edition = "2018"
 
 [lib]
-
 name = "statrs"
 path = "src/lib.rs"
 
+[features]
+nightly = []
+
 [dependencies]
-rand = "0.7.3"
-nalgebra = "0.23.0"
+rand = "0.8"
+nalgebra = { version = "0.26", features = ["rand"] }
 approx = "0.4.0"
 num-traits = "0.2.14"
 lazy_static = "1.4.0"
diff --git a/benches/order_statistics.rs b/benches/order_statistics.rs
index 71f36f5b..fa6fdd26 100644
--- a/benches/order_statistics.rs
+++ b/benches/order_statistics.rs
@@ -6,14 +6,14 @@ use statrs::statistics::*;
 
 fn bench_order_statistic(c: &mut Criterion) {
     let mut rng = thread_rng();
-    let to_random_owned = |data: &[f64]| -> Vec<f64> {
+    let to_random_owned = |data: &[f64]| -> Data<Vec<f64>> {
         let mut rng = thread_rng();
         let mut owned = data.to_vec();
         owned.shuffle(&mut rng);
-        owned
+        Data::new(owned)
     };
     let k = black_box(rng.gen());
-    let tau = black_box(rng.gen_range(0.0, 1.0));
+    let tau = black_box(rng.gen_range(0.0..1.0));
     let mut group = c.benchmark_group("order statistic");
     let data: Vec<_> = (0..100).map(|x| x as f64).collect();
     group.bench_function("order_statistic", |b| {
diff --git a/src/distribution/beta.rs b/src/distribution/beta.rs
index d384bc5b..a477ff4d 100644
--- a/src/distribution/beta.rs
+++ b/src/distribution/beta.rs
@@ -369,7 +369,7 @@ impl Continuous<f64, f64> for Beta {
 }
 
 #[rustfmt::skip]
-#[cfg(test)]
+#[cfg(all(test, feature = "nightly"))]
 mod tests {
     use super::*;
     use crate::consts::ACC;
diff --git a/src/distribution/chi.rs b/src/distribution/chi.rs
index 83f490f5..fc674f76 100644
--- a/src/distribution/chi.rs
+++ b/src/distribution/chi.rs
@@ -341,14 +341,6 @@ mod tests {
         assert_almost_eq!(expected, x, acc);
     }
 
-    fn test_is_nan<F>(freedom: f64, eval: F)
-    where
-        F: Fn(Chi) -> f64,
-    {
-        let x = get_value(freedom, eval);
-        assert!(x.is_nan());
-    }
-
     #[test]
     fn test_create() {
         create_case(1.0);
diff --git a/src/distribution/dirichlet.rs b/src/distribution/dirichlet.rs
index 2b1ccddd..0cedf169 100644
--- a/src/distribution/dirichlet.rs
+++ b/src/distribution/dirichlet.rs
@@ -5,9 +5,7 @@ use crate::{prec, Result, StatsError};
 use nalgebra::DMatrix;
 use nalgebra::DVector;
 use nalgebra::{
-    base::allocator::Allocator,
-    base::{dimension::DimName, MatrixN, VectorN},
-    DefaultAllocator, Dim, DimMin, U1,
+    base::allocator::Allocator, base::dimension::DimName, DefaultAllocator, Dim, DimMin, U1,
 };
 use rand::Rng;
 use std::f64;
diff --git a/src/distribution/discrete_uniform.rs b/src/distribution/discrete_uniform.rs
index 503db2d7..a29d2a50 100644
--- a/src/distribution/discrete_uniform.rs
+++ b/src/distribution/discrete_uniform.rs
@@ -53,7 +53,7 @@ impl DiscreteUniform {
 
 impl ::rand::distributions::Distribution<f64> for DiscreteUniform {
     fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
-        rng.gen_range(self.min, self.max + 1) as f64
+        rng.gen_range(self.min..=self.max) as f64
     }
 }
 
diff --git a/src/distribution/gamma.rs b/src/distribution/gamma.rs
index cbdf6d92..33435ab8 100644
--- a/src/distribution/gamma.rs
+++ b/src/distribution/gamma.rs
@@ -322,7 +322,7 @@ pub fn sample_unchecked<R: Rng + ?Sized>(rng: &mut R, shape: f64, rate: f64) ->
     }
 }
 
-#[cfg(test)]
+#[cfg(all(test, feature = "nightly"))]
 mod tests {
     use super::*;
     use crate::consts::ACC;
diff --git a/src/distribution/internal.rs b/src/distribution/internal.rs
index 70401449..eebe53f3 100644
--- a/src/distribution/internal.rs
+++ b/src/distribution/internal.rs
@@ -18,6 +18,7 @@ pub mod test {
     use crate::consts::ACC;
     use crate::distribution::{Continuous, ContinuousCDF, Discrete, DiscreteCDF};
 
+    #[cfg(feature = "nightly")]
     #[macro_export]
     macro_rules! testing_boiler {
         ($arg:ty, $dist:ty) => {
@@ -58,6 +59,7 @@ pub mod test {
                 assert_abs_diff_eq!(expected, x, epsilon = acc);
             }
 
+            #[allow(dead_code)] // This is not used by all distributions.
             fn test_none<F, T>(arg: $arg, eval: F)
             where
                 F: Fn($dist) -> Option<T>,
diff --git a/src/distribution/laplace.rs b/src/distribution/laplace.rs
index 92de5f74..a0a85e94 100644
--- a/src/distribution/laplace.rs
+++ b/src/distribution/laplace.rs
@@ -81,7 +81,7 @@ impl Laplace {
 
 impl ::rand::distributions::Distribution<f64> for Laplace {
     fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
-        let x: f64 = rng.gen_range(-0.5, 0.5);
+        let x: f64 = rng.gen_range(-0.5..0.5);
         self.location - self.scale * x.signum() * (1. - 2. * x).ln()
     }
 }
@@ -280,12 +280,6 @@ mod tests {
         n.unwrap()
     }
 
-    fn create_case(location: f64, scale: f64) {
-        let n = try_create(location, scale);
-        assert_eq!(location, n.location);
-        assert_eq!(scale, n.scale);
-    }
-
     fn bad_create_case(location: f64, scale: f64) {
         let n = Laplace::new(location, scale);
         assert!(n.is_err());
@@ -302,7 +296,6 @@ mod tests {
 
     fn test_is_nan<F>(location: f64, scale: f64, eval: F)
     where
-        F: Fn(laplace::Laplace) -> f64,
         F: Fn(Laplace) -> f64,
     {
         let n = try_create(location, scale);
@@ -405,7 +398,7 @@ mod tests {
     #[test]
     fn test_max() {
         test_case(0.0, 1.0, INF, |l| l.max());
-  }
+    }
 
     #[test]
     fn test_density() {
diff --git a/src/distribution/multivariate_normal.rs b/src/distribution/multivariate_normal.rs
index 6e600ee2..bc0216f5 100644
--- a/src/distribution/multivariate_normal.rs
+++ b/src/distribution/multivariate_normal.rs
@@ -3,9 +3,8 @@ use crate::distribution::Normal;
 use crate::statistics::{Max, MeanN, Min, Mode, VarianceN};
 use crate::{Result, StatsError};
 use nalgebra::{
-    base::allocator::Allocator,
-    base::{dimension::DimName, MatrixN, VectorN},
-    Cholesky, DefaultAllocator, Dim, DimMin, LU, U1,
+    base::allocator::Allocator, base::dimension::DimName, Cholesky, DefaultAllocator, Dim, DimMin,
+    LU, U1,
 };
 use nalgebra::{DMatrix, DVector};
 use rand::Rng;
@@ -212,8 +211,8 @@ mod tests  {
     use core::fmt::Debug;
     use nalgebra::base::allocator::Allocator;
     use nalgebra::{
-        DefaultAllocator, Dim, DimMin, DimName, Matrix2, Matrix3, MatrixN, Vector2, Vector3,
-        VectorN, U1, U2,
+        DefaultAllocator, Dim, DimMin, DimName, Matrix2, Matrix3, Vector2, Vector3,
+        U1, U2,
     };
 
     fn try_create(mean: Vec<f64>, covariance: Vec<f64>) -> MultivariateNormal
diff --git a/src/distribution/students_t.rs b/src/distribution/students_t.rs
index 0c2d13e1..23036285 100644
--- a/src/distribution/students_t.rs
+++ b/src/distribution/students_t.rs
@@ -1060,450 +1060,4 @@ mod tests {
         test(0.999, 120.0, 3.160);
         test(0.9995, 120.0, 3.373);
     }
-
-    #[test]
-    fn test_inv_cdf() {
-        let test = |x: f64, freedom: f64, expected: f64| {
-            use approx::*;
-            let d = StudentsT::new(0., 1., freedom).unwrap();
-            // Checks that left == right to 4 significant figures, unlike
-            // test_almost() which uses decimal places
-            assert_relative_eq!(d.inverse_cdf(x), expected, max_relative = 0.001);
-        };
-
-        // This test checks our implementation against the whole t-table
-        // copied from https://en.wikipedia.org/wiki/Student's_t-distribution
-
-        test(0.75, 1.0, 1.000);
-        test(0.8, 1.0, 1.376);
-        test(0.85, 1.0, 1.963);
-        test(0.9, 1.0, 3.078);
-        test(0.95, 1.0, 6.314);
-        test(0.975, 1.0, 12.71);
-        test(0.99, 1.0, 31.82);
-        test(0.995, 1.0, 63.66);
-        test(0.9975, 1.0, 127.3);
-        test(0.999, 1.0, 318.3);
-        test(0.9995, 1.0, 636.6);
-
-        test(0.75, 002.0, 0.816);
-        // test(0.8, 002.0, 1.080);  // We get 1.061 for some reason...
-        test(0.85, 002.0, 1.386);
-        test(0.9, 002.0, 1.886);
-        test(0.95, 002.0, 2.920);
-        test(0.975, 002.0, 4.303);
-        test(0.99, 002.0, 6.965);
-        test(0.995, 002.0, 9.925);
-        test(0.9975, 002.0, 14.09);
-        test(0.999, 002.0, 22.33);
-        test(0.9995, 002.0, 31.60);
-
-        test(0.75, 003.0, 0.765);
-        test(0.8, 003.0, 0.978);
-        test(0.85, 003.0, 1.250);
-        test(0.9, 003.0, 1.638);
-        test(0.95, 003.0, 2.353);
-        test(0.975, 003.0, 3.182);
-        test(0.99, 003.0, 4.541);
-        test(0.995, 003.0, 5.841);
-        test(0.9975, 003.0, 7.453);
-        test(0.999, 003.0, 10.21);
-        test(0.9995, 003.0, 12.92);
-
-        test(0.75, 004.0, 0.741);
-        test(0.8, 004.0, 0.941);
-        test(0.85, 004.0, 1.190);
-        test(0.9, 004.0, 1.533);
-        test(0.95, 004.0, 2.132);
-        test(0.975, 004.0, 2.776);
-        test(0.99, 004.0, 3.747);
-        test(0.995, 004.0, 4.604);
-        test(0.9975, 004.0, 5.598);
-        test(0.999, 004.0, 7.173);
-        test(0.9995, 004.0, 8.610);
-
-        test(0.75, 005.0, 0.727);
-        test(0.8, 005.0, 0.920);
-        test(0.85, 005.0, 1.156);
-        test(0.9, 005.0, 1.476);
-        test(0.95, 005.0, 2.015);
-        test(0.975, 005.0, 2.571);
-        test(0.99, 005.0, 3.365);
-        test(0.995, 005.0, 4.032);
-        test(0.9975, 005.0, 4.773);
-        test(0.999, 005.0, 5.893);
-        test(0.9995, 005.0, 6.869);
-
-        test(0.75, 006.0, 0.718);
-        test(0.8, 006.0, 0.906);
-        test(0.85, 006.0, 1.134);
-        test(0.9, 006.0, 1.440);
-        test(0.95, 006.0, 1.943);
-        test(0.975, 006.0, 2.447);
-        test(0.99, 006.0, 3.143);
-        test(0.995, 006.0, 3.707);
-        test(0.9975, 006.0, 4.317);
-        test(0.999, 006.0, 5.208);
-        test(0.9995, 006.0, 5.959);
-
-        test(0.75, 007.0, 0.711);
-        test(0.8, 007.0, 0.896);
-        test(0.85, 007.0, 1.119);
-        test(0.9, 007.0, 1.415);
-        test(0.95, 007.0, 1.895);
-        test(0.975, 007.0, 2.365);
-        test(0.99, 007.0, 2.998);
-        test(0.995, 007.0, 3.499);
-        test(0.9975, 007.0, 4.029);
-        test(0.999, 007.0, 4.785);
-        test(0.9995, 007.0, 5.408);
-
-        test(0.75, 008.0, 0.706);
-        test(0.8, 008.0, 0.889);
-        test(0.85, 008.0, 1.108);
-        test(0.9, 008.0, 1.397);
-        test(0.95, 008.0, 1.860);
-        test(0.975, 008.0, 2.306);
-        test(0.99, 008.0, 2.896);
-        test(0.995, 008.0, 3.355);
-        test(0.9975, 008.0, 3.833);
-        test(0.999, 008.0, 4.501);
-        test(0.9995, 008.0, 5.041);
-
-        test(0.75, 009.0, 0.703);
-        test(0.8, 009.0, 0.883);
-        test(0.85, 009.0, 1.100);
-        test(0.9, 009.0, 1.383);
-        test(0.95, 009.0, 1.833);
-        test(0.975, 009.0, 2.262);
-        test(0.99, 009.0, 2.821);
-        test(0.995, 009.0, 3.250);
-        test(0.9975, 009.0, 3.690);
-        test(0.999, 009.0, 4.297);
-        test(0.9995, 009.0, 4.781);
-
-        test(0.75, 010.0, 0.700);
-        test(0.8, 010.0, 0.879);
-        test(0.85, 010.0, 1.093);
-        test(0.9, 010.0, 1.372);
-        test(0.95, 010.0, 1.812);
-        test(0.975, 010.0, 2.228);
-        test(0.99, 010.0, 2.764);
-        test(0.995, 010.0, 3.169);
-        test(0.9975, 010.0, 3.581);
-        test(0.999, 010.0, 4.144);
-        test(0.9995, 010.0, 4.587);
-
-        test(0.75, 011.0, 0.697);
-        test(0.8, 011.0, 0.876);
-        test(0.85, 011.0, 1.088);
-        test(0.9, 011.0, 1.363);
-        test(0.95, 011.0, 1.796);
-        test(0.975, 011.0, 2.201);
-        test(0.99, 011.0, 2.718);
-        test(0.995, 011.0, 3.106);
-        test(0.9975, 011.0, 3.497);
-        test(0.999, 011.0, 4.025);
-        test(0.9995, 011.0, 4.437);
-
-        test(0.75, 012.0, 0.695);
-        test(0.8, 012.0, 0.873);
-        test(0.85, 012.0, 1.083);
-        test(0.9, 012.0, 1.356);
-        test(0.95, 012.0, 1.782);
-        test(0.975, 012.0, 2.179);
-        test(0.99, 012.0, 2.681);
-        test(0.995, 012.0, 3.055);
-        test(0.9975, 012.0, 3.428);
-        test(0.999, 012.0, 3.930);
-        test(0.9995, 012.0, 4.318);
-
-        test(0.75, 013.0, 0.694);
-        test(0.8, 013.0, 0.870);
-        test(0.85, 013.0, 1.079);
-        test(0.9, 013.0, 1.350);
-        test(0.95, 013.0, 1.771);
-        test(0.975, 013.0, 2.160);
-        test(0.99, 013.0, 2.650);
-        test(0.995, 013.0, 3.012);
-        test(0.9975, 013.0, 3.372);
-        test(0.999, 013.0, 3.852);
-        test(0.9995, 013.0, 4.221);
-
-        test(0.75, 014.0, 0.692);
-        test(0.8, 014.0, 0.868);
-        test(0.85, 014.0, 1.076);
-        test(0.9, 014.0, 1.345);
-        test(0.95, 014.0, 1.761);
-        test(0.975, 014.0, 2.145);
-        test(0.99, 014.0, 2.624);
-        test(0.995, 014.0, 2.977);
-        test(0.9975, 014.0, 3.326);
-        test(0.999, 014.0, 3.787);
-        test(0.9995, 014.0, 4.140);
-
-        test(0.75, 015.0, 0.691);
-        test(0.8, 015.0, 0.866);
-        test(0.85, 015.0, 1.074);
-        test(0.9, 015.0, 1.341);
-        test(0.95, 015.0, 1.753);
-        test(0.975, 015.0, 2.131);
-        test(0.99, 015.0, 2.602);
-        test(0.995, 015.0, 2.947);
-        test(0.9975, 015.0, 3.286);
-        test(0.999, 015.0, 3.733);
-        test(0.9995, 015.0, 4.073);
-
-        test(0.75, 016.0, 0.690);
-        test(0.8, 016.0, 0.865);
-        test(0.85, 016.0, 1.071);
-        test(0.9, 016.0, 1.337);
-        test(0.95, 016.0, 1.746);
-        test(0.975, 016.0, 2.120);
-        test(0.99, 016.0, 2.583);
-        test(0.995, 016.0, 2.921);
-        test(0.9975, 016.0, 3.252);
-        test(0.999, 016.0, 3.686);
-        test(0.9995, 016.0, 4.015);
-
-        test(0.75, 017.0, 0.689);
-        test(0.8, 017.0, 0.863);
-        test(0.85, 017.0, 1.069);
-        test(0.9, 017.0, 1.333);
-        test(0.95, 017.0, 1.740);
-        test(0.975, 017.0, 2.110);
-        test(0.99, 017.0, 2.567);
-        test(0.995, 017.0, 2.898);
-        test(0.9975, 017.0, 3.222);
-        test(0.999, 017.0, 3.646);
-        test(0.9995, 017.0, 3.965);
-
-        test(0.75, 018.0, 0.688);
-        test(0.8, 018.0, 0.862);
-        test(0.85, 018.0, 1.067);
-        test(0.9, 018.0, 1.330);
-        test(0.95, 018.0, 1.734);
-        test(0.975, 018.0, 2.101);
-        test(0.99, 018.0, 2.552);
-        test(0.995, 018.0, 2.878);
-        test(0.9975, 018.0, 3.197);
-        test(0.999, 018.0, 3.610);
-        test(0.9995, 018.0, 3.922);
-
-        test(0.75, 019.0, 0.688);
-        test(0.8, 019.0, 0.861);
-        test(0.85, 019.0, 1.066);
-        test(0.9, 019.0, 1.328);
-        test(0.95, 019.0, 1.729);
-        test(0.975, 019.0, 2.093);
-        test(0.99, 019.0, 2.539);
-        test(0.995, 019.0, 2.861);
-        test(0.9975, 019.0, 3.174);
-        test(0.999, 019.0, 3.579);
-        test(0.9995, 019.0, 3.883);
-
-        test(0.75, 020.0, 0.687);
-        test(0.8, 020.0, 0.860);
-        test(0.85, 020.0, 1.064);
-        test(0.9, 020.0, 1.325);
-        test(0.95, 020.0, 1.725);
-        test(0.975, 020.0, 2.086);
-        test(0.99, 020.0, 2.528);
-        test(0.995, 020.0, 2.845);
-        test(0.9975, 020.0, 3.153);
-        test(0.999, 020.0, 3.552);
-        test(0.9995, 020.0, 3.850);
-
-        test(0.75, 021.0, 0.686);
-        test(0.8, 021.0, 0.859);
-        test(0.85, 021.0, 1.063);
-        test(0.9, 021.0, 1.323);
-        test(0.95, 021.0, 1.721);
-        test(0.975, 021.0, 2.080);
-        test(0.99, 021.0, 2.518);
-        test(0.995, 021.0, 2.831);
-        test(0.9975, 021.0, 3.135);
-        test(0.999, 021.0, 3.527);
-        test(0.9995, 021.0, 3.819);
-
-        test(0.75, 022.0, 0.686);
-        test(0.8, 022.0, 0.858);
-        test(0.85, 022.0, 1.061);
-        test(0.9, 022.0, 1.321);
-        test(0.95, 022.0, 1.717);
-        test(0.975, 022.0, 2.074);
-        test(0.99, 022.0, 2.508);
-        test(0.995, 022.0, 2.819);
-        test(0.9975, 022.0, 3.119);
-        test(0.999, 022.0, 3.505);
-        test(0.9995, 022.0, 3.792);
-
-        test(0.75, 023.0, 0.685);
-        test(0.8, 023.0, 0.858);
-        test(0.85, 023.0, 1.060);
-        test(0.9, 023.0, 1.319);
-        test(0.95, 023.0, 1.714);
-        test(0.975, 023.0, 2.069);
-        test(0.99, 023.0, 2.500);
-        test(0.995, 023.0, 2.807);
-        test(0.9975, 023.0, 3.104);
-        test(0.999, 023.0, 3.485);
-        test(0.9995, 023.0, 3.767);
-
-        test(0.75, 024.0, 0.685);
-        test(0.8, 024.0, 0.857);
-        test(0.85, 024.0, 1.059);
-        test(0.9, 024.0, 1.318);
-        test(0.95, 024.0, 1.711);
-        test(0.975, 024.0, 2.064);
-        test(0.99, 024.0, 2.492);
-        test(0.995, 024.0, 2.797);
-        test(0.9975, 024.0, 3.091);
-        test(0.999, 024.0, 3.467);
-        test(0.9995, 024.0, 3.745);
-
-        test(0.75, 025.0, 0.684);
-        test(0.8, 025.0, 0.856);
-        test(0.85, 025.0, 1.058);
-        test(0.9, 025.0, 1.316);
-        test(0.95, 025.0, 1.708);
-        test(0.975, 025.0, 2.060);
-        test(0.99, 025.0, 2.485);
-        test(0.995, 025.0, 2.787);
-        test(0.9975, 025.0, 3.078);
-        test(0.999, 025.0, 3.450);
-        test(0.9995, 025.0, 3.725);
-
-        test(0.75, 026.0, 0.684);
-        test(0.8, 026.0, 0.856);
-        test(0.85, 026.0, 1.058);
-        test(0.9, 026.0, 1.315);
-        test(0.95, 026.0, 1.706);
-        test(0.975, 026.0, 2.056);
-        test(0.99, 026.0, 2.479);
-        test(0.995, 026.0, 2.779);
-        test(0.9975, 026.0, 3.067);
-        test(0.999, 026.0, 3.435);
-        test(0.9995, 026.0, 3.707);
-
-        test(0.75, 027.0, 0.684);
-        test(0.8, 027.0, 0.855);
-        test(0.85, 027.0, 1.057);
-        test(0.9, 027.0, 1.314);
-        test(0.95, 027.0, 1.703);
-        test(0.975, 027.0, 2.052);
-        test(0.99, 027.0, 2.473);
-        test(0.995, 027.0, 2.771);
-        test(0.9975, 027.0, 3.057);
-        test(0.999, 027.0, 3.421);
-        test(0.9995, 027.0, 3.690);
-
-        test(0.75, 028.0, 0.683);
-        test(0.8, 028.0, 0.855);
-        test(0.85, 028.0, 1.056);
-        test(0.9, 028.0, 1.313);
-        test(0.95, 028.0, 1.701);
-        test(0.975, 028.0, 2.048);
-        test(0.99, 028.0, 2.467);
-        test(0.995, 028.0, 2.763);
-        test(0.9975, 028.0, 3.047);
-        test(0.999, 028.0, 3.408);
-        test(0.9995, 028.0, 3.674);
-
-        test(0.75, 029.0, 0.683);
-        test(0.8, 029.0, 0.854);
-        test(0.85, 029.0, 1.055);
-        test(0.9, 029.0, 1.311);
-        test(0.95, 029.0, 1.699);
-        test(0.975, 029.0, 2.045);
-        test(0.99, 029.0, 2.462);
-        test(0.995, 029.0, 2.756);
-        test(0.9975, 029.0, 3.038);
-        test(0.999, 029.0, 3.396);
-        test(0.9995, 029.0, 3.659);
-
-        test(0.75, 030.0, 0.683);
-        test(0.8, 030.0, 0.854);
-        test(0.85, 030.0, 1.055);
-        test(0.9, 030.0, 1.310);
-        test(0.95, 030.0, 1.697);
-        test(0.975, 030.0, 2.042);
-        test(0.99, 030.0, 2.457);
-        test(0.995, 030.0, 2.750);
-        test(0.9975, 030.0, 3.030);
-        test(0.999, 030.0, 3.385);
-        test(0.9995, 030.0, 3.646);
-
-        test(0.75, 040.0, 0.681);
-        test(0.8, 040.0, 0.851);
-        test(0.85, 040.0, 1.050);
-        test(0.9, 040.0, 1.303);
-        test(0.95, 040.0, 1.684);
-        test(0.975, 040.0, 2.021);
-        test(0.99, 040.0, 2.423);
-        test(0.995, 040.0, 2.704);
-        test(0.9975, 040.0, 2.971);
-        test(0.999, 040.0, 3.307);
-        test(0.9995, 040.0, 3.551);
-
-        test(0.75, 050.0, 0.679);
-        test(0.8, 050.0, 0.849);
-        test(0.85, 050.0, 1.047);
-        test(0.9, 050.0, 1.299);
-        test(0.95, 050.0, 1.676);
-        test(0.975, 050.0, 2.009);
-        test(0.99, 050.0, 2.403);
-        test(0.995, 050.0, 2.678);
-        test(0.9975, 050.0, 2.937);
-        test(0.999, 050.0, 3.261);
-        test(0.9995, 050.0, 3.496);
-
-        test(0.75, 060.0, 0.679);
-        test(0.8, 060.0, 0.848);
-        test(0.85, 060.0, 1.045);
-        test(0.9, 060.0, 1.296);
-        test(0.95, 060.0, 1.671);
-        test(0.975, 060.0, 2.000);
-        test(0.99, 060.0, 2.390);
-        test(0.995, 060.0, 2.660);
-        test(0.9975, 060.0, 2.915);
-        test(0.999, 060.0, 3.232);
-        test(0.9995, 060.0, 3.460);
-
-        test(0.75, 080.0, 0.678);
-        test(0.8, 080.0, 0.846);
-        test(0.85, 080.0, 1.043);
-        test(0.9, 080.0, 1.292);
-        test(0.95, 080.0, 1.664);
-        test(0.975, 080.0, 1.990);
-        test(0.99, 080.0, 2.374);
-        test(0.995, 080.0, 2.639);
-        test(0.9975, 080.0, 2.887);
-        test(0.999, 080.0, 3.195);
-        test(0.9995, 080.0, 3.416);
-
-        test(0.75, 100.0, 0.677);
-        test(0.8, 100.0, 0.845);
-        test(0.85, 100.0, 1.042);
-        test(0.9, 100.0, 1.290);
-        test(0.95, 100.0, 1.660);
-        test(0.975, 100.0, 1.984);
-        test(0.99, 100.0, 2.364);
-        test(0.995, 100.0, 2.626);
-        test(0.9975, 100.0, 2.871);
-        test(0.999, 100.0, 3.174);
-        test(0.9995, 100.0, 3.390);
-
-        test(0.75, 120.0, 0.677);
-        test(0.8, 120.0, 0.845);
-        test(0.85, 120.0, 1.041);
-        test(0.9, 120.0, 1.289);
-        test(0.95, 120.0, 1.658);
-        test(0.975, 120.0, 1.980);
-        test(0.99, 120.0, 2.358);
-        test(0.995, 120.0, 2.617);
-        test(0.9975, 120.0, 2.860);
-        test(0.999, 120.0, 3.160);
-        test(0.9995, 120.0, 3.373);
-    }
 }
diff --git a/src/lib.rs b/src/lib.rs
index 7481b662..b8970d61 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -29,8 +29,8 @@
 #![allow(clippy::many_single_char_names)]
 #![allow(unused_imports)]
 #![forbid(unsafe_code)]
-#![cfg_attr(test, feature(unboxed_closures))]
-#![cfg_attr(test, feature(fn_traits))]
+#![cfg_attr(all(test, feature = "nightly"), feature(unboxed_closures))]
+#![cfg_attr(all(test, feature = "nightly"), feature(fn_traits))]
 
 #[macro_use]
 extern crate approx;
@@ -42,10 +42,10 @@ extern crate lazy_static;
 macro_rules! assert_almost_eq {
     ($a:expr, $b:expr, $prec:expr) => {
         if !$crate::prec::almost_eq($a, $b, $prec) {
-            panic!(format!(
+            panic!(
                 "assertion failed: `abs(left - right) < {:e}`, (left: `{}`, right: `{}`)",
                 $prec, $a, $b
-            ));
+            );
         }
     };
 }
diff --git a/src/statistics/iter_statistics.rs b/src/statistics/iter_statistics.rs
index 04e22821..3a53d835 100644
--- a/src/statistics/iter_statistics.rs
+++ b/src/statistics/iter_statistics.rs
@@ -175,7 +175,7 @@ where
         for x in self {
             let borrow = *x.borrow();
             let borrow2 = match iter.next() {
-                None => panic!(format!("{}", StatsError::ContainersMustBeSameLength)),
+                None => panic!("{}", StatsError::ContainersMustBeSameLength),
                 Some(x) => *x.borrow(),
             };
             let old_mean2 = mean2;
@@ -185,7 +185,7 @@ where
             comoment += (borrow - mean1) * (borrow2 - old_mean2);
         }
         if iter.next().is_some() {
-            panic!(format!("{}", StatsError::ContainersMustBeSameLength));
+            panic!("{}", StatsError::ContainersMustBeSameLength);
         }
 
         if n > 1.0 {
@@ -205,7 +205,7 @@ where
         for x in self {
             let borrow = *x.borrow();
             let borrow2 = match iter.next() {
-                None => panic!(format!("{}", StatsError::ContainersMustBeSameLength)),
+                None => panic!("{}", StatsError::ContainersMustBeSameLength),
                 Some(x) => *x.borrow(),
             };
             let old_mean2 = mean2;
@@ -215,7 +215,7 @@ where
             comoment += (borrow - mean1) * (borrow2 - old_mean2);
         }
         if iter.next().is_some() {
-            panic!(format!("{}", StatsError::ContainersMustBeSameLength));
+            panic!("{}", StatsError::ContainersMustBeSameLength)
         }
         if n > 0.0 {
             comoment / n
diff --git a/src/statistics/traits.rs b/src/statistics/traits.rs
index 5e3766f6..d264d719 100644
--- a/src/statistics/traits.rs
+++ b/src/statistics/traits.rs
@@ -1,7 +1,5 @@
 use ::nalgebra::{
-    base::allocator::Allocator,
-    base::{dimension::DimName, MatrixN, VectorN},
-    DefaultAllocator, Dim, DimMin, U1,
+    base::allocator::Allocator, base::dimension::DimName, DefaultAllocator, Dim, DimMin, U1,
 };
 use ::num_traits::float::Float;
 


Test patch: