Did I find the right examples for you? yes no      Crawl my project      Python Jobs

# cogent.maths.unifrac.fast_tree.bool_descendants

All Samples(12)  |  Call(10)  |  Derive(0)  |  Import(2)

```from cogent.util.unit_test import TestCase, main
from cogent.parse.tree import DndParser
from cogent.maths.unifrac.fast_tree import (count_envs, sum_env_dict,
index_envs, get_branch_lengths, index_tree, bind_to_array,
bind_to_parent_array, _is_parent_empty, delete_empty_parents,
```
```        bound_indices = bind_to_array(self.nodes, cur_count_array)
total_bl = sum(self.branch_lengths)
bool_descendants(bound_indices)
env_bl_sums, env_bl_ufracs = env_unique_fraction(self.branch_lengths, cur_count_array)
# env A has 0 unique bl, B has 4, C has 1
```
```        bound_indices = bind_to_array(self.old_nodes, cur_count_array)
total_bl = sum(self.old_branch_lengths)
bool_descendants(bound_indices)

env_bl_sums, env_bl_ufracs = env_unique_fraction(self.old_branch_lengths, cur_count_array)
```
```    def test_delete_empty_parents(self):
"""delete_empty_parents should remove empty parents from bound indices"""
id_to_node, node_first_last = index_tree(self.t)
bound_indices = bind_to_array(node_first_last, self.count_array[:,0:1])
bool_descendants(bound_indices)
```
```        a = [1,0,0]
a = [0,0,1]
bool_descendants(bindings)
self.assertEqual(a, \
array([[0,1,0],[0,1,0],[0,1,0],[1,0,0],[0,1,0],[1,0,0],\
```

```from cogent.util.unit_test import TestCase, main
from cogent.parse.tree import DndParser
from cogent.maths.unifrac.fast_tree import (count_envs, sum_env_dict,
index_envs, get_branch_lengths, index_tree, bind_to_array,
bind_to_parent_array, _is_parent_empty, delete_empty_parents,
```
```        bound_indices = bind_to_array(self.nodes, cur_count_array)
total_bl = sum(self.branch_lengths)
bool_descendants(bound_indices)
env_bl_sums, env_bl_ufracs = env_unique_fraction(self.branch_lengths, cur_count_array)
# env A has 0 unique bl, B has 4, C has 1
```
```        bound_indices = bind_to_array(self.old_nodes, cur_count_array)
total_bl = sum(self.old_branch_lengths)
bool_descendants(bound_indices)

env_bl_sums, env_bl_ufracs = env_unique_fraction(self.old_branch_lengths, cur_count_array)
```
```    def test_delete_empty_parents(self):
"""delete_empty_parents should remove empty parents from bound indices"""
id_to_node, node_first_last = index_tree(self.t)
bound_indices = bind_to_array(node_first_last, self.count_array[:,0:1])
bool_descendants(bound_indices)
```
```        a = [1,0,0]
a = [0,0,1]
bool_descendants(bindings)
self.assertEqual(a, \
array([[0,1,0],[0,1,0],[0,1,0],[1,0,0],[0,1,0],[1,0,0],\
```