本文整理匯總了Python中Cerebrum.Utils.separate_entries方法的典型用法代碼示例。如果您正苦於以下問題:Python Utils.separate_entries方法的具體用法?Python Utils.separate_entries怎麽用?Python Utils.separate_entries使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cerebrum.Utils
的用法示例。
在下文中一共展示了Utils.separate_entries方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: separate_entries_test
# 需要導入模塊: from Cerebrum import Utils [as 別名]
# 或者: from Cerebrum.Utils import separate_entries [as 別名]
def separate_entries_test():
""" Utils.separate_entries() filters as expected. """
rows = [MetaRow(('a', 'b', 'c'))(row) for row in ((1, 2, 3),
(1, 2, 4),
(1, 3, 4))]
result = Utils.separate_entries(rows, ('a', 1), ('b', 2), ('c', 3))
# Should keep rows[0], reject rows[1], rows[2]
assert rows[0] in result[0] and rows[1] in result[1]
test_cases = [{'predicate': (('a', 1), ('b', 2), ('c', 3)),
'keep': 1, 'reject': 2}, # Matches 1st row
{'predicate': (('a', 1),),
'keep': 3, 'reject': 0}, # Matches no rows
{'predicate': (('a', 2), ),
'keep': 0, 'reject': 3}, # Matches all rows
{'predicate': (('a', 1), ('c', 4)),
'keep': 2, 'reject': 1}] # Matches 1st, 3rd row
for test_case in test_cases:
result = Utils.separate_entries(rows, *(test_case['predicate']))
assert (len(result[0]) == test_case['keep'] and
len(result[1]) == test_case['reject'])