Skip to content

Commit

Permalink
Add test unrelated to the preceding commits
Browse files Browse the repository at this point in the history
  • Loading branch information
ales-erjavec committed Aug 29, 2016
1 parent 2ef7f74 commit 4f3fc78
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Orange/tests/test_clustering_hierarchical.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ def test_prunning(self):
pruned = hierarchical.prune(self.cluster, height=10)
self.assertTrue(c.height >= 10 for c in hierarchical.preorder(pruned))

top = hierarchical.top_clusters(self.cluster, 3)
self.assertEqual(len(top), 3)

top = hierarchical.top_clusters(self.cluster, len(self.matrix))
self.assertEqual(len(top), len(self.matrix))
self.assertTrue(all(n.is_leaf for n in top))

def test_form(self):
m = [[0, 2, 3, 4],
[2, 0, 6, 7],
Expand Down Expand Up @@ -117,6 +124,14 @@ def score(root):
self.assertGreater(score_unordered, score_ordered)
self.assertEqual(score_ordered, 21.0)

def test_table_clustering(self):
table = Orange.data.Table(numpy.eye(3))
tree = hierarchical.data_clustering(table, linkage="single")
numpy.testing.assert_almost_equal(tree.value.height, numpy.sqrt(2))

tree = hierarchical.feature_clustering(table)
numpy.testing.assert_almost_equal(tree.value.height, 0.75)


class TestTree(unittest.TestCase):
def test_tree(self):
Expand Down

0 comments on commit 4f3fc78

Please sign in to comment.