當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。