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

Skip to content

Commit 6277624

Browse files
kelsiegrsolvents
authored andcommitted
Added silverman and scott tests.
1 parent 0555ef1 commit 6277624

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

lib/matplotlib/tests/test_mlab.py

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,6 +2806,122 @@ def test_kde_bandwidth_method(self):
28062806
assert_almost_equal(kdepdf.all(), kdepdf2.all())
28072807
kdepdf3 = gkde3.evaluate(xs)
28082808
assert_almost_equal(kdepdf.all(), kdepdf3.all())
2809+
2810+
#CUSTOM TESTS
2811+
class ksdensity_custom_tests(object):
2812+
class ksdensity_custom_tests(object):
2813+
def test_no_data(self):
2814+
"""Pass no data into the GaussianKDE class."""
2815+
mygauss = mlab.GaussianKDE([])
2816+
self.assertRaises(ValueError,
2817+
"`dataset` input should have multiple elements.")
2818+
2819+
def test_single_dataset_element(self):
2820+
"""Pass a single dataset element into the GaussianKDE class."""
2821+
myguass = mlab.GuassianKDE([42])
2822+
self.assertRaises(ValueError,
2823+
"`dataset` input should have multiple elements.")
2824+
2825+
def test_silverman_multidim_dataset(self):
2826+
"""Use a multi-dimensional array as the dataset and test silverman's
2827+
output"""
2828+
x1 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
2829+
mygauss = mlab.GaussianKDE(x1, "silverman")
2830+
othergauss = stats.gaussian_kde(x1)
2831+
expected_output = othergauss.covariance_factor()
2832+
assert mygauss.covariance_factor() == expected_output
2833+
2834+
def test_silverman_singledim_dataset(self):
2835+
"""Use a single dimension list as the dataset and test silverman's
2836+
output."""
2837+
x1 = np.array([-7, -5, 1, 4, 5])
2838+
mygauss = mlab.GaussianKDE(x1, "silverman")
2839+
othergauss = stats.gaussian_kde(x1)
2840+
expected_output = othergauss.covariance_factor()
2841+
assert mygauss.covariance_factor() == expected_output
2842+
2843+
def test_scott_multidim_dataset(self):
2844+
"""Use a multi-dimensional array as the dataset and test scott's output
2845+
"""
2846+
x1 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
2847+
mygauss = mlab.GaussianKDE(x1, "scott")
2848+
othergauss = stats.gaussian_kde(x1)
2849+
expected_output = othergauss.covariance_factor()
2850+
assert mygauss.covariance_factor() == expected_output
2851+
2852+
def test_scott_singledim_dataset(self):
2853+
"""Use a single-dimensional array as the dataset and test scott's
2854+
output"""
2855+
x1 = np.array([-7, -5, 1, 4, 5])
2856+
mygauss = mlab.GaussianKDE(x1, "scott")
2857+
othergauss = stats.gaussian_kde(x1)
2858+
expected_output = othergauss.covariance_factor()
2859+
assert mygauss.covariance_factor() == expected_output
2860+
2861+
def test_scalar_multidim_dataset(self):
2862+
"""Use a multi-dimensional array as the dataset and test a scalar's
2863+
output"""
2864+
pass
2865+
2866+
def test_scalar_singledim_dataset(self):
2867+
"""Use a single-dimensional array as the dataset and test the scalar's
2868+
output"""
2869+
pass
2870+
2871+
def test_callable_empty_dataset(self):
2872+
"""Use an empty array as the dataset and test the callable's cov factor
2873+
"""
2874+
pass
2875+
2876+
def test_callable_multidim_dataset(self):
2877+
"""Use an multi-dimensional array as the dataset and test the
2878+
callable's cov factor"""
2879+
pass
2880+
2881+
def test_callable_singledim_dataset(self):
2882+
"""Use a single-dimensional array as the dataset and test the
2883+
callable's cov factor"""
2884+
pass
2885+
2886+
def test_wrong_bw_method(self):
2887+
"""Test the error message that should be called when bw is invalid."""
2888+
pass
2889+
2890+
2891+
class evaluate_tests(object):
2892+
def test_evaluate_diff_dim(self):
2893+
"""Test the evaluate method when the dim's of dataset and points are
2894+
different dimensions"""
2895+
pass
2896+
2897+
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+
2902+
def test_evaluate_point_dim_not_one(self):
2903+
"""Test"""
2904+
pass
2905+
2906+
def test_evaluate_numm_equal_dataset_dim(self):
2907+
pass
2908+
2909+
def test_evaluate_equal_dim_and_numm_lt(self):
2910+
"""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+
28092925

28102926

28112927
#*****************************************************************

0 commit comments

Comments
 (0)