Exemplo n.º 1
0
    def test_equal(self):
        unlabelled_leaf = RankTree(children=[])
        self.assertEqual(unlabelled_leaf, unlabelled_leaf)
        self.assertTrue(unlabelled_leaf.shape_equal(unlabelled_leaf))

        leaf_zero = RankTree(children=[], label=0)
        leaf_one = RankTree(children=[], label=1)
        leaf_two = RankTree(children=[], label=2)
        self.assertEqual(leaf_zero, leaf_zero)
        self.assertNotEqual(leaf_zero, leaf_one)
        self.assertTrue(leaf_zero.shape_equal(leaf_one))

        tree1 = RankTree(children=[leaf_zero, leaf_one])
        self.assertEqual(tree1, tree1)
        self.assertNotEqual(tree1, unlabelled_leaf)
        self.assertFalse(tree1.shape_equal(unlabelled_leaf))

        tree2 = RankTree(children=[leaf_two, leaf_one])
        self.assertNotEqual(tree1, tree2)
        self.assertTrue(tree1.shape_equal(tree2))
Exemplo n.º 2
0
    def test_equal(self):
        unlabelled_leaf = RankTree(children=[])
        assert unlabelled_leaf == unlabelled_leaf
        assert unlabelled_leaf.shape_equal(unlabelled_leaf)

        leaf_zero = RankTree(children=[], label=0)
        leaf_one = RankTree(children=[], label=1)
        leaf_two = RankTree(children=[], label=2)
        assert leaf_zero == leaf_zero
        assert leaf_zero != leaf_one
        assert leaf_zero.shape_equal(leaf_one)

        tree1 = RankTree(children=[leaf_zero, leaf_one])
        assert tree1 == tree1
        assert tree1 != unlabelled_leaf
        assert not tree1.shape_equal(unlabelled_leaf)

        tree2 = RankTree(children=[leaf_two, leaf_one])
        assert tree1 != tree2
        assert tree1.shape_equal(tree2)