本文整理匯總了Python中Bio.Pathway.Rep.HashSet.intersection方法的典型用法代碼示例。如果您正苦於以下問題:Python HashSet.intersection方法的具體用法?Python HashSet.intersection怎麽用?Python HashSet.intersection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Bio.Pathway.Rep.HashSet
的用法示例。
在下文中一共展示了HashSet.intersection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testSetOps
# 需要導入模塊: from Bio.Pathway.Rep import HashSet [as 別名]
# 或者: from Bio.Pathway.Rep.HashSet import intersection [as 別名]
def testSetOps(self):
n = HashSet()
a = HashSet(['a', 'b', 'c'])
b = HashSet(['a', 'd', 'e', 'f'])
c = HashSet(['g', 'h'])
# union
self.assertEqual(a.union(b), HashSet(['a','b','c','d','e','f']), "incorrect union")
self.assertEqual(a.union(n), a, "incorrect union with empty set")
# intersection
self.assertEqual(a.intersection(b), HashSet(['a']), "incorrect intersection")
self.assertEqual(a.intersection(c), HashSet(), "incorrect intersection")
self.assertEqual(a.intersection(n), HashSet(), "incorrect intersection with empty set")
# difference
self.assertEqual(a.difference(b), HashSet(['b','c']), "incorrect difference")
self.assertEqual(a.difference(c), HashSet(['a','b','c']), "incorrect difference")
self.assertEqual(b.difference(a), HashSet(['d','e','f']), "incorrect difference")
# cartesian product
self.assertEqual(a.cartesian(c), HashSet([('a','g'),('a','h'),
('b','g'),('b','h'),
('c','g'),('c','h')]),
"incorrect cartesian product")
self.assertEqual(a.cartesian(n), HashSet(), "incorrect cartesian product")