1- use ndarray:: array;
1+ use ndarray:: { array, Array1 } ;
2+ use approx:: assert_abs_diff_eq;
23
34use csaps:: GridCubicSmoothingSpline ;
45
@@ -19,5 +20,19 @@ fn test_make_surface() {
1920 let s = GridCubicSmoothingSpline :: new ( & x, & y)
2021 . make ( ) . unwrap ( ) ;
2122
22- assert ! ( s. spline( ) . is_some( ) )
23+ let coeffs_expected = array ! [
24+ [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ] ,
25+ [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ] ,
26+ [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ] ,
27+ [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ] ,
28+ [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 4. , 4. , 4. ] ,
29+ [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 4. , 4. , 4. ] ,
30+ [ 0. , 0. , 0. , 0. , 0. , 0. , 1. , 1. , 1. , 1. , 2. , 3. ] ,
31+ [ 0. , 0. , 0. , 0. , 0. , 0. , 1. , 1. , 1. , 5. , 6. , 7. ] ,
32+ ] ;
33+
34+ let smooth: Array1 < f64 > = s. smooth ( ) . iter ( ) . map ( |v| v. unwrap ( ) ) . collect ( ) ;
35+
36+ assert_abs_diff_eq ! ( smooth, array![ 0.8999999999999999 , 0.8999999999999999 ] ) ;
37+ assert_abs_diff_eq ! ( s. spline( ) . unwrap( ) . coeffs( ) , coeffs_expected)
2338}
0 commit comments