本文整理汇总了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")