本文整理汇总了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))
示例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
示例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}))