本文整理匯總了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}))