def test_is_forking_point(): t = Tree(0) t.add_child(Tree(1)) t.add_child(Tree(2)) nt.ok_(is_forking_point(t)) t.add_child(Tree(3)) nt.ok_(is_forking_point(t))
def branch_order(tree_section): '''Branching order of a tree section The branching order is defined as the depth of the tree section. Note: The first level has branch order 0. ''' node = tree_section[-1] bo = sum(1 for _ in tr.iforking_point(node, tr.iupstream)) return bo - 2 if tr.is_forking_point(node) else bo - 1
def test_is_forking_point_false(): t = Tree(0) nt.ok_(not is_forking_point(t)) t.add_child(Tree(1)) nt.ok_(not is_forking_point(t))