diff options
| author | Alexander <alexanderkabua@gmail.com> | 2022-05-18 14:15:38 +0300 |
|---|---|---|
| committer | Alexander <alexanderkabua@gmail.com> | 2022-05-18 14:15:38 +0300 |
| commit | 532900261597f70befd5bfebfe199689d3f7f0bd (patch) | |
| tree | 58fc162ff4a20901c97d9fb3a13b3e9e88e1ba2b /src | |
| parent | e1b9f68ff7c16a9411add9beabcdbfa545d1679b (diff) | |
| download | correlation_rust-532900261597f70befd5bfebfe199689d3f7f0bd.tar.gz | |
code formatting
Diffstat (limited to 'src')
| -rw-r--r-- | src/correlations.rs | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/correlations.rs b/src/correlations.rs index e938fb2..715f21c 100644 --- a/src/correlations.rs +++ b/src/correlations.rs @@ -117,6 +117,23 @@ impl<'a> Compute<'a> { } } + + + pub fn filter_top(result:Vec<(f64,f64)>,n:Option<usize>) -> Vec<(f64,f64)>{ + + match n{Some(n_top) => { + + result + } + + None => + { + result + + } + } + } + pub fn sorter(results:&mut Vec<(f64,f64)>){ //naive sorter @@ -360,11 +377,19 @@ mod test { let compute_obj = Compute::new( ',', "pearson", + "/home/kabui/correlation_rust/src/matrix_80.txt", + &x_vals, + ); + + let computation2 = Compute::new( + ',', + "pearson", "/home/kabui/correlation_rust/src/db300.txt", &x_vals, ); - //assert_eq!(vec![(1.2, 1.5)], compute_obj.compute()) + assert_eq!(vec![(1.2, 1.5)], compute_obj.compute()); + assert_eq!(vec![(1.2,1.5)],computation2.compute()); } #[test] @@ -381,4 +406,18 @@ mod test { } + + #[test] + fn test_n_top(){ + + let mut a1 = vec![(1.2,1.0),(1.3,0.5),(1.3,7.)]; + + let new_vec = Compute::filter_top(a1, Some(2)); + + assert_eq!(new_vec,vec![(1.2,1.0),(1.3,0.5)]) + + + + + } } |
