def test_prunning(self):
        pruned = hierarchical.prune(self.cluster, level=2)
        depths = hierarchical.cluster_depths(pruned)
        self.assertTrue(all(d <= 2 for d in depths.values()))

        pruned = hierarchical.prune(self.cluster, height=10)
        self.assertTrue(c.height >= 10 for c in hierarchical.preorder(pruned))
    def test_prunning(self):
        pruned = hierarchical.prune(self.cluster, level=2)
        depths = hierarchical.cluster_depths(pruned)
        self.assertTrue(all(d <= 2 for d in depths.values()))

        pruned = hierarchical.prune(self.cluster, height=10)
        self.assertTrue(c.height >= 10 for c in hierarchical.preorder(pruned))
Example #3
0
    def test_prunning(self):
        pruned1 = hier.pruned(self.cluster, level=2)
        depths = hier.cluster_depths(pruned1)
        self.assertTrue(all(d <= 2 for d in depths.values()))

        pruned2 = hier.pruned(self.cluster, height=10)
        self.assertTrue(c.height >= 10 for c in hier.preorder(pruned2))

        pruned3 = hier.pruned(self.cluster, condition=lambda cl: len(cl) <= 3)
        self.assertTrue(len(c) > 3 for c in hier.preorder(pruned3))
Example #4
0
    def test_prunning(self):
        pruned1 = hier.pruned(self.cluster, level=2)
        depths = hier.cluster_depths(pruned1)
        self.assertTrue(all(d <= 2 for d in depths.values()))

        pruned2 = hier.pruned(self.cluster, height=10)
        self.assertTrue(c.height >= 10 for c in hier.preorder(pruned2))

        pruned3 = hier.pruned(self.cluster, condition=lambda cl: len(cl) <= 3)
        self.assertTrue(len(c) > 3 for c in hier.preorder(pruned3))
Example #5
0
    def test_prunning(self):
        pruned = hierarchical.prune(self.cluster, level=2)
        depths = hierarchical.cluster_depths(pruned)
        self.assertTrue(all(d <= 2 for d in depths.values()))

        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))

        top1 = hierarchical.top_clusters(self.cluster, len(self.matrix) + 1)
        self.assertEqual(top1, top)
    def test_prunning(self):
        pruned = hierarchical.prune(self.cluster, level=2)
        depths = hierarchical.cluster_depths(pruned)
        self.assertTrue(all(d <= 2 for d in depths.values()))

        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))

        top1 = hierarchical.top_clusters(self.cluster, len(self.matrix) + 1)
        self.assertEqual(top1, top)