Esempio n. 1
0
    def test_get_children(self):
        forest = Forest()
        self.assertEqual(forest.get_children(), [])

        forest = Forest([Tree(1), Tree(3), Tree(10)])
        n_children = [1, 3, 10]
        i = 0
        for child in forest.get_children():
            self.assertEqual(child.get_node_position(), i)
            self.assertEqual(child.n_children(), n_children[i])
            i += 1
Esempio n. 2
0
 def test_record(self):
     forest = Forest([Tree(2), Tree(2), Tree(2)])
     for dummy in range(5):
         for child in forest.get_children():
             if np.random.rand() > 0.5:
                 child.split()
     forest.record(1)
     for tree in forest.traverse():
         self.assertTrue(tree.is_marked(1))