當前位置: 首頁>>代碼示例>>Python>>正文


Python HashSet.union方法代碼示例

本文整理匯總了Python中Bio.Pathway.Rep.HashSet.union方法的典型用法代碼示例。如果您正苦於以下問題:Python HashSet.union方法的具體用法?Python HashSet.union怎麽用?Python HashSet.union使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Bio.Pathway.Rep.HashSet的用法示例。


在下文中一共展示了HashSet.union方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testSetOps

# 需要導入模塊: from Bio.Pathway.Rep import HashSet [as 別名]
# 或者: from Bio.Pathway.Rep.HashSet import union [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")
開發者ID:,項目名稱:,代碼行數:24,代碼來源:


注:本文中的Bio.Pathway.Rep.HashSet.union方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。