当前位置: 首页>>代码示例>>Python>>正文


Python Rep.HashSet类代码示例

本文整理汇总了Python中Bio.Pathway.Rep.HashSet的典型用法代码示例。如果您正苦于以下问题:Python HashSet类的具体用法?Python HashSet怎么用?Python HashSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HashSet类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testList

 def testList(self):
     a = HashSet(['a', 'b', 'c', 'd', 'e'])
     l = a.list()
     l.sort()
     self.assertEqual(l, ['a', 'b', 'c', 'd', 'e'], "incorrect list")
     l = []
     self.assertTrue('e' in a, "set rep exposure")
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: remove_node

 def remove_node(self, node):
     """Removes node and all edges connected to it."""
     if node not in self.__adjacency_list:
         raise ValueError("Unknown node: " + str(node))
     # remove node (and all out-edges) from adjacency list
     del self.__adjacency_list[node]
     # remove all in-edges from adjacency list
     for n in self.__adjacency_list:
         self.__adjacency_list[n] = HashSet(filter(lambda x,node=node: x[0] is not node,
                                                   self.__adjacency_list[n].list()))
     # remove all refering pairs in label map
     for label in self.__label_map.keys():
         lm = HashSet(filter(lambda x,node=node: \
                             (x[0] is not node) and (x[1] is not node),
                             self.__label_map[label].list()))
         # remove the entry completely if the label is now unused
         if lm.empty():
             del self.__label_map[label]
         else:
             self.__label_map[label] = lm
开发者ID:BlogomaticProject,项目名称:Blogomatic,代码行数:20,代码来源:MultiGraph.py

示例3: testLen

 def testLen(self):
     a = HashSet()
     self.assertEqual(len(a), 0, "incorrect default size")
     a.add('a')
     a.add('b')
     self.assertEqual(len(a), 2, "incorrect size")
     a.remove('b')
     self.assertEqual(len(a), 1, "incorrect size after removal")
     a.add('a')
     self.assertEqual(len(a), 1, "incorrect size after duplicate add")
开发者ID:,项目名称:,代码行数:10,代码来源:

示例4: testLen

 def testLen(self):
     a = HashSet()
     self.failUnless(len(a) == 0, "incorrect default size")
     a.add('a')
     a.add('b')
     self.failUnless(len(a) == 2, "incorrect size")
     a.remove('b')
     self.failUnless(len(a) == 1, "incorrect size after removal")
     a.add('a')
     self.failUnless(len(a) == 1, "incorrect size after duplicate add")
开发者ID:andyoberlin,项目名称:biopython,代码行数:10,代码来源:test_Pathway.py

示例5: testSetOps

 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:,项目名称:,代码行数:22,代码来源:

示例6: testContains

 def testContains(self):
     n = HashSet()
     self.assertTrue('a' not in n, "element in empty set")
     self.assertTrue(not n.contains('a'), "element in empty set (2)")
     a = HashSet(['a','b','c','d'])
     self.assertTrue('a' in a, "contained element not found")
     self.assertTrue('d' in a, "contained element not found")
     self.assertTrue('e' not in a, "not contained element found")
     self.assertTrue(68 not in a, "not contained element found")
     self.assertTrue(a.contains('a'), "contained element not found (2)")
     self.assertTrue(a.contains('d'), "contained element not found (2)")
     self.assertTrue(not a.contains('e'), "not contained element found (2)")
     self.assertTrue(not a.contains(68), "not contained element found (2)")
开发者ID:,项目名称:,代码行数:13,代码来源:

示例7: children

 def children(self, parent):
     """Returns a list of unique children for parent."""
     s = HashSet([x[0] for x in self.child_edges(parent)])
     return s.list()
开发者ID:BlogomaticProject,项目名称:Blogomatic,代码行数:4,代码来源:MultiGraph.py

示例8: parents

 def parents(self, child):
     """Returns a list of unique parents for child."""
     s = HashSet([x[0] for x in self.parent_edges(child)])
     return s.list()
开发者ID:BlogomaticProject,项目名称:Blogomatic,代码行数:4,代码来源:MultiGraph.py

示例9: species

 def species(self):
     """Returns a list of the species in this system."""
     s = HashSet(reduce(lambda s,x: s + x,
                        [x.species() for x in self.reactions()], []))
     return s.list()
开发者ID:BlogomaticProject,项目名称:Blogomatic,代码行数:5,代码来源:__init__.py

示例10: __init__

 def __init__(self, reactions = []):
     """Initializes a new System object."""
     self.__reactions = HashSet(reactions)
开发者ID:BlogomaticProject,项目名称:Blogomatic,代码行数:3,代码来源:__init__.py


注:本文中的Bio.Pathway.Rep.HashSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。