From 068f43de107ffbe1cf1188558b59c10365266cd9 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Tue, 9 Jan 2018 15:45:03 -0500 Subject: [PATCH] adds test for exception if no data is present --- src/py/crankshaft/test/test_clustering_kmeans.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/py/crankshaft/test/test_clustering_kmeans.py b/src/py/crankshaft/test/test_clustering_kmeans.py index 3756b7e..c118d34 100644 --- a/src/py/crankshaft/test/test_clustering_kmeans.py +++ b/src/py/crankshaft/test/test_clustering_kmeans.py @@ -71,7 +71,6 @@ class KMeansNonspatialTest(unittest.TestCase): random_seeds.set_random_seeds(1234) kmeans = Kmeans(FakeDataProvider(data_raw)) clusters = kmeans.nonspatial('subquery', ['col1', 'col2'], 2) - print str([c[0] for c in clusters]) cl1 = clusters[0][0] cl2 = clusters[3][0] @@ -81,3 +80,8 @@ class KMeansNonspatialTest(unittest.TestCase): self.assertEqual(val[0], cl1) else: self.assertEqual(val[0], cl2) + + # raises exception for no data + with self.assertRaises(Exception): + kmeans = Kmeans(FakeDataProvider([])) + kmeans.nonspatial('subquery', ['col1', 'col2'], 2)