當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。