@@ -2889,39 +2889,60 @@ def test_wrong_bw_method(self):
2889
2889
2890
2890
2891
2891
class evaluate_tests (object ):
2892
+
2893
+ @knownfailureif (True )
2892
2894
def test_evaluate_diff_dim (self ):
2893
2895
"""Test the evaluate method when the dim's of dataset and points are
2894
- different dimensions"""
2895
- pass
2896
-
2896
+ different dimensions"""
2897
+ x1 = np .arange (3 , 10 , 2 )
2898
+ kde = mlab .GaussianKDE (x1 )
2899
+ x2 = np .arange (3 , 12 , 2 )
2900
+ y_expected = [0 , 0 , 0 , 0 , 0 ]
2901
+ y = kde .evaluate (x2 )
2902
+
2903
+ assert_array_almost_equal (y , y_expected , 7 )
2904
+
2897
2905
def test_evaluate_inv_dim (self ):
2898
- """ Invert the dimensions. I.e Give the dataset a dimension of 1
2899
- [3,2,4], and the points will have a dimension of 3 [[3],[2],[4]]"""
2900
- pass
2901
-
2906
+ """ Invert the dimensions. I.e Give the dataset a dimension of 1 [3,2,4],
2907
+ and the points will have a dimension of 3 [[3],[2],[4]]. ValueError
2908
+ should be raised"""
2909
+ x1 = np .arange (3 , 10 , 2 )
2910
+ kde = mlab .GaussianKDE (x1 )
2911
+ x2 = np .array ([[3 ],[5 ],[7 ],[9 ]])
2912
+
2913
+ assert_raises (ValueError , kde .evaluate , x2 )
2914
+
2915
+ @knownfailureif (True )
2916
+ def test_evaluate_dim_and_num (self ):
2917
+ """ Tests if evaluated against a one by one array"""
2918
+ x1 = np .arange (3 , 10 , 2 )
2919
+ x2 = np .array ([3 ])
2920
+ kde = mlab .GaussianKDE (x1 )
2921
+ y_expected = [0 ]
2922
+ y = kde .evaluate (x2 )
2923
+
2924
+ assert_array_almost_equal (y , y_expected , 7 )
2925
+
2926
+
2902
2927
def test_evaluate_point_dim_not_one (self ):
2903
2928
"""Test"""
2904
- pass
2905
-
2906
- def test_evaluate_numm_equal_dataset_dim (self ):
2907
- pass
2908
-
2929
+ x1 = np .arange (3 , 10 , 2 )
2930
+ x2 = [np .arange (3 , 10 , 2 ), np .arange (3 , 10 , 2 )]
2931
+ kde = mlab .GaussianKDE (x1 )
2932
+
2933
+ assert_raises (ValueError , kde .evaluate , x2 )
2934
+
2935
+ @knownfailureif (True )
2909
2936
def test_evaluate_equal_dim_and_numm_lt (self ):
2910
2937
"""Test when line 3810 fails"""
2911
- pass
2912
-
2913
- def test_evaluate_equal_dim_and_numm_gte (self ):
2914
- """Test when line 3810 passes"""
2915
- pass
2916
-
2917
- def test_evaluate_nequal_dim_and_numm_lt (self ):
2918
- """Test when line 3810 fails"""
2919
- pass
2920
-
2921
- def test_evaluate_nequal_dim_and_numm_gte (self ):
2922
- """Test when line 3810 passes"""
2923
- pass
2924
-
2938
+ x1 = np .arange (3 , 10 , 2 )
2939
+ x2 = np .arange (3 , 8 , 2 )
2940
+ kde = mlab .GaussianKDE (x1 )
2941
+ y_expected = [0 , 0 , 0 ]
2942
+ y = kde .evaluate (x2 )
2943
+
2944
+ assert_array_almost_equal (y , y_expected , 7 )
2945
+
2925
2946
2926
2947
2927
2948
#*****************************************************************
0 commit comments