当前位置: 首页>>代码示例>>Python>>正文


Python Tree.match方法代码示例

本文整理汇总了Python中icarus.util.Tree.match方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.match方法的具体用法?Python Tree.match怎么用?Python Tree.match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在icarus.util.Tree的用法示例。


在下文中一共展示了Tree.match方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_match

# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import match [as 别名]
 def test_match(self):
     t = {'a': {'b': 1}, 'c': 2, 'd': {'e': 3}}
     pos_match_equal = {'a': {'b': 1}, 'c': 2, 'd': {'e': 3}}
     pos_match_subset = {'a': {'b': 1}, 'd': {'e': 3}}
     neg_match_diff = {'a': {'b': 2}, 'c': 2, 'd': {'e': 3}}
     neg_match_superset = {'a': {'b': 1}, 'c': 2, 'd': {'e': 3}, 'f': 3}
     tree = Tree(t)
     self.assertTrue(tree.match(pos_match_equal))
     self.assertTrue(tree.match(pos_match_subset))
     self.assertFalse(tree.match(neg_match_diff))
     self.assertFalse(tree.match(neg_match_superset))
开发者ID:Jeswang,项目名称:icarus,代码行数:13,代码来源:test_tree.py

示例2: filter

# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import match [as 别名]
 def filter(self, condition):
     """Return subset of results matching specific conditions
     
     Parameters
     ----------
     condition : dict
         Dictionary listing all parameters and values to be matched in the
         results set. Each parameter, i.e., each key of the dictionary must
         be an iterable object containing the path in the parameters tree
         to the required parameter 
     metrics : dict, optional
         List of metrics to be reported
     
     Returns
     -------
     filtered_results : ResultSet
         List of 2-tuples of filtered results, where the first element is a
         tree of all experiment parameters and the second value is 
         a tree with experiment results.
     """
     filtered_resultset = ResultSet()
     for parameters, results in self._results:
         parameters = Tree(parameters)
         if parameters.match(condition):
             filtered_resultset.add(parameters, results)
     return filtered_resultset
开发者ID:David-Loughnane,项目名称:distributed-project,代码行数:28,代码来源:readwrite.py

示例3: test_match_empty_tree

# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import match [as 别名]
 def test_match_empty_tree(self):
     tree = Tree()
     self.assertFalse(tree.match({'a': 1}))
开发者ID:Jeswang,项目名称:icarus,代码行数:5,代码来源:test_tree.py


注:本文中的icarus.util.Tree.match方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。