|
49 | 49 | /// # Example
|
50 | 50 | ///
|
51 | 51 | /// ```
|
52 |
| - /// extern crate ndarray; |
53 |
| - /// extern crate ndarray_stats; |
54 | 52 | /// use ndarray::{aview2, arr2};
|
55 | 53 | /// use ndarray_stats::CorrelationExt;
|
56 | 54 | ///
|
|
98 | 96 | ///
|
99 | 97 | /// variables is zero and division by zero panics for type A.
|
100 | 98 | /// ```
|
101 |
| - /// extern crate ndarray; |
102 |
| - /// extern crate ndarray_stats; |
103 | 99 | /// use ndarray::arr2;
|
104 | 100 | /// use ndarray_stats::CorrelationExt;
|
105 | 101 | ///
|
@@ -175,31 +171,31 @@ mod cov_tests {
|
175 | 171 | use super::*;
|
176 | 172 | use ndarray::array;
|
177 | 173 | use ndarray_rand::RandomExt;
|
178 |
| - use quickcheck::quickcheck; |
| 174 | + use quickcheck_macros::quickcheck; |
179 | 175 | use rand;
|
180 | 176 | use rand::distributions::Uniform;
|
181 | 177 |
|
182 |
| - quickcheck! { |
183 |
| - fn constant_random_variables_have_zero_covariance_matrix(value: f64) -> bool { |
184 |
| - let n_random_variables = 3; |
185 |
| - let n_observations = 4; |
186 |
| - let a = Array::from_elem((n_random_variables, n_observations), value); |
187 |
| - a.cov(1.).all_close( |
188 |
| - &Array::zeros((n_random_variables, n_random_variables)), |
189 |
| - 1e-8 |
190 |
| - ) |
191 |
| - } |
| 178 | + #[quickcheck] |
| 179 | + fn constant_random_variables_have_zero_covariance_matrix(value: f64) -> bool { |
| 180 | + let n_random_variables = 3; |
| 181 | + let n_observations = 4; |
| 182 | + let a = Array::from_elem((n_random_variables, n_observations), value); |
| 183 | + a.cov(1.).all_close( |
| 184 | + &Array::zeros((n_random_variables, n_random_variables)), |
| 185 | + 1e-8, |
| 186 | + ) |
| 187 | + } |
192 | 188 |
|
193 |
| - fn covariance_matrix_is_symmetric(bound: f64) -> bool { |
194 |
| - let n_random_variables = 3; |
195 |
| - let n_observations = 4; |
196 |
| - let a = Array::random( |
197 |
| - (n_random_variables, n_observations), |
198 |
| - Uniform::new(-bound.abs(), bound.abs()) |
199 |
| - ); |
200 |
| - let covariance = a.cov(1.); |
201 |
| - covariance.all_close(&covariance.t(), 1e-8) |
202 |
| - } |
| 189 | + #[quickcheck] |
| 190 | + fn covariance_matrix_is_symmetric(bound: f64) -> bool { |
| 191 | + let n_random_variables = 3; |
| 192 | + let n_observations = 4; |
| 193 | + let a = Array::random( |
| 194 | + (n_random_variables, n_observations), |
| 195 | + Uniform::new(-bound.abs(), bound.abs()), |
| 196 | + ); |
| 197 | + let covariance = a.cov(1.); |
| 198 | + covariance.all_close(&covariance.t(), 1e-8) |
203 | 199 | }
|
204 | 200 |
|
205 | 201 | #[test]
|
@@ -277,28 +273,31 @@ mod pearson_correlation_tests {
|
277 | 273 | use super::*;
|
278 | 274 | use ndarray::array;
|
279 | 275 | use ndarray_rand::RandomExt;
|
280 |
| - use quickcheck::quickcheck; |
| 276 | + use quickcheck_macros::quickcheck; |
281 | 277 | use rand::distributions::Uniform;
|
282 | 278 |
|
283 |
| - quickcheck! { |
284 |
| - fn output_matrix_is_symmetric(bound: f64) -> bool { |
285 |
| - let n_random_variables = 3; |
286 |
| - let n_observations = 4; |
287 |
| - let a = Array::random( |
288 |
| - (n_random_variables, n_observations), |
289 |
| - Uniform::new(-bound.abs(), bound.abs()) |
290 |
| - ); |
291 |
| - let pearson_correlation = a.pearson_correlation(); |
292 |
| - pearson_correlation.all_close(&pearson_correlation.t(), 1e-8) |
293 |
| - } |
| 279 | + #[quickcheck] |
| 280 | + fn output_matrix_is_symmetric(bound: f64) -> bool { |
| 281 | + let n_random_variables = 3; |
| 282 | + let n_observations = 4; |
| 283 | + let a = Array::random( |
| 284 | + (n_random_variables, n_observations), |
| 285 | + Uniform::new(-bound.abs(), bound.abs()), |
| 286 | + ); |
| 287 | + let pearson_correlation = a.pearson_correlation(); |
| 288 | + pearson_correlation.all_close(&pearson_correlation.t(), 1e-8) |
| 289 | + } |
294 | 290 |
|
295 |
| - fn constant_random_variables_have_nan_correlation(value: f64) -> bool { |
296 |
| - let n_random_variables = 3; |
297 |
| - let n_observations = 4; |
298 |
| - let a = Array::from_elem((n_random_variables, n_observations), value); |
299 |
| - let pearson_correlation = a.pearson_correlation(); |
300 |
| - pearson_correlation.iter().map(|x| x.is_nan()).fold(true, |acc, flag| acc & flag) |
301 |
| - } |
| 291 | + #[quickcheck] |
| 292 | + fn constant_random_variables_have_nan_correlation(value: f64) -> bool { |
| 293 | + let n_random_variables = 3; |
| 294 | + let n_observations = 4; |
| 295 | + let a = Array::from_elem((n_random_variables, n_observations), value); |
| 296 | + let pearson_correlation = a.pearson_correlation(); |
| 297 | + pearson_correlation |
| 298 | + .iter() |
| 299 | + .map(|x| x.is_nan()) |
| 300 | + .fold(true, |acc, flag| acc & flag) |
302 | 301 | }
|
303 | 302 |
|
304 | 303 | #[test]
|
|
0 commit comments