From e589dc0daedd3bd3d8736465cbc2ff6124515038 Mon Sep 17 00:00:00 2001 From: Marc Haubenstock Date: Sun, 28 Jul 2019 14:22:42 +0200 Subject: [PATCH] added test comments --- src/linalg/convolution.rs | 9 +------ tests/linalg/convolution.rs | 54 +++++++++---------------------------- 2 files changed, 14 insertions(+), 49 deletions(-) diff --git a/src/linalg/convolution.rs b/src/linalg/convolution.rs index eba9dec9..aa269a18 100644 --- a/src/linalg/convolution.rs +++ b/src/linalg/convolution.rs @@ -162,10 +162,9 @@ impl DMatrix { //TODO: rest ? - } -impl MatrixMN where DefaultAllocator: Allocator { +impl MatrixMN where DefaultAllocator: Allocator { /// Returns the convolution of the target vector and a kernel. /// /// # Arguments @@ -184,8 +183,6 @@ impl MatrixMN where C2: Dim, S2: Storage { - - let mat_rows = self.nrows() as i32; let mat_cols = self.ncols() as i32; @@ -193,13 +190,11 @@ impl MatrixMN where convolve(&self, &kernel,&mut conv,mat_rows,mat_cols); - conv } //TODO: rest ? - } @@ -213,7 +208,6 @@ fn convolve(mat: &MatrixMN, kernel: &Matrix, DefaultAllocator: Allocator { - let ker_rows = kernel.data.shape().0.value() as i32; let ker_cols = kernel.data.shape().1.value() as i32; @@ -225,7 +219,6 @@ fn convolve(mat: &MatrixMN, kernel: &Matrix(); diff --git a/tests/linalg/convolution.rs b/tests/linalg/convolution.rs index 69783cd9..3aa0ee2a 100644 --- a/tests/linalg/convolution.rs +++ b/tests/linalg/convolution.rs @@ -118,50 +118,22 @@ fn convolve_valid_check(){ } -//// >>> convolve([1,2,3,4],[1,2],"same") -//// array([ 1, 4, 7, 10]) -//#[test] -//fn convolve_same_integers_check(){ -// // Static Tests -// let actual_s = Vector4::new(1, 4, 7, 10); -// let expected_s = Vector4::new(1, 2, 3, 4).convolve_same(Vector2::new(1, 2)); // -// assert!(relative_eq!(actual_s, expected_s, epsilon = 1.0e-7)); +// mat([ 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1]) // -// // Dynamic Tests -// let actual_d = DVector::from_vec(vec![1, 4, 7, 10]); -// let expected_d = DVector::from_vec(vec![1, 2, 3, 4]).convolve_same(DVector::from_vec(vec![1, 2])); +// kernel([ 0, 1, 0, +// 1, 1, 1, +// 0, 1, 0,]) // -// assert!(relative_eq!(actual_d, expected_d, epsilon = 1.0e-7)); -// -// // Panic Tests -// // These really only apply to dynamic sized vectors -// assert!( -// panic::catch_unwind(|| { -// DVector::from_vec(vec![1, 2]).convolve_same(DVector::from_vec(vec![1, 2, 3, 4])); -// }).is_err() -// ); -// -// assert!( -// panic::catch_unwind(|| { -// DVector::::from_vec(vec![]).convolve_same(DVector::from_vec(vec![1, 2, 3, 4])); -// }).is_err() -// ); -// -// assert!( -// panic::catch_unwind(|| { -// DVector::from_vec(vec![1, 2, 3, 4]).convolve_same(DVector::::from_vec(vec![])); -// }).is_err() -// ); -//} - -// -// Should mimic calculations in Python's scipy library -// >>>from scipy.signal import convolve -// - -// >>> convolve([1,2,3,4],[1,2],"same") -// array([ 1, 4, 7, 10]) +// res([ 3, 4, 4, 4, 3, +// 4, 5, 5, 5, 4, +// 4, 5, 5, 5, 4, +// 4, 5, 5, 5, 4, +// 3, 4, 4, 4, 3]) #[test] fn convolve_same_mat_check(){ let actual_s = Matrix5::from_vec( vec![3.0,4.0,4.0,4.0,3.0,4.0,5.0,5.0,5.0,4.0,4.0,5.0,5.0,5.0,4.0,4.0,5.0,5.0,5.0,4.0,3.0,4.0,4.0,4.0,3.0]);