Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39c66a9

Browse files
grdloksolvents
authored andcommitted
implementations of the evaluate tests
Conflicts: lib/matplotlib/tests/test_mlab.py
1 parent 6277624 commit 39c66a9

File tree

1 file changed

+47
-26
lines changed

1 file changed

+47
-26
lines changed

lib/matplotlib/tests/test_mlab.py

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,39 +2889,60 @@ def test_wrong_bw_method(self):
28892889

28902890

28912891
class evaluate_tests(object):
2892+
2893+
@knownfailureif(True)
28922894
def test_evaluate_diff_dim(self):
28932895
"""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+
28972905
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+
29022927
def test_evaluate_point_dim_not_one(self):
29032928
"""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)
29092936
def test_evaluate_equal_dim_and_numm_lt(self):
29102937
"""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+
29252946

29262947

29272948
#*****************************************************************

0 commit comments

Comments
 (0)