skbio.tree.TreeNode.find_by_func¶
- TreeNode.find_by_func(func)[源代码]¶
查找给定函数的所有节点
状态:从0.4.0开始实验。
此搜索方法基于当前子树,而不是根。
- 参数:
func (a function) -- 接受TreeNode并返回 True 或 False 在哪里 True 指示要生成的节点
- 生成器:
TreeNode --节点找到者 func .
参见
示例
>>> from skbio import TreeNode >>> tree = TreeNode.read(["((a,b)c,(d,e)f);"]) >>> func = lambda x: x.parent == tree.find('c') >>> [n.name for n in tree.find_by_func(func)] ['a', 'b']