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


Python deque.__init__方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from collections import deque [as 別名]
# 或者: from collections.deque import __init__ [as 別名]
def __init__(self, n, cutoff=1, backoff=None):
        """
        Construct an I{n}-gram stochastic tagger.  The tagger must be trained
        using the L{train()} method before being used to tag data.
        
        @param n: The order of the new C{tagger.Ngram}.
        @type n: int
        @type cutoff: C{int}
        @param cutoff: A count-cutoff for the tagger's frequency
            distribution.  If the tagger saw fewer than
            C{cutoff} examples of a given context in training,
            then it will return a tag of C{None} for that context.
        """
        if n < 2: raise ValueError('n must be greater than 1')
        self._model = {}
        self._n = n
        self._cutoff = cutoff
        self._history = Window(n-1)
        self._backoff = backoff 
開發者ID:rafasashi,項目名稱:razzy-spinner,代碼行數:21,代碼來源:ngram.py

示例2: test_basics

# 需要導入模塊: from collections import deque [as 別名]
# 或者: from collections.deque import __init__ [as 別名]
def test_basics(self):
        d = deque(xrange(-5125, -5000))
        d.__init__(xrange(200))
        for i in xrange(200, 400):
            d.append(i)
        for i in reversed(xrange(-200, 0)):
            d.appendleft(i)
        self.assertEqual(list(d), range(-200, 400))
        self.assertEqual(len(d), 600)

        left = [d.popleft() for i in xrange(250)]
        self.assertEqual(left, range(-200, 50))
        self.assertEqual(list(d), range(50, 400))

        right = [d.pop() for i in xrange(250)]
        right.reverse()
        self.assertEqual(right, range(150, 400))
        self.assertEqual(list(d), range(50, 150)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:20,代碼來源:test_deque.py

示例3: test_basics

# 需要導入模塊: from collections import deque [as 別名]
# 或者: from collections.deque import __init__ [as 別名]
def test_basics(self):
        d = deque(range(-5125, -5000))
        d.__init__(range(200))
        for i in range(200, 400):
            d.append(i)
        for i in reversed(range(-200, 0)):
            d.appendleft(i)
        self.assertEqual(list(d), list(range(-200, 400)))
        self.assertEqual(len(d), 600)

        left = [d.popleft() for i in range(250)]
        self.assertEqual(left, list(range(-200, 50)))
        self.assertEqual(list(d), list(range(50, 400)))

        right = [d.pop() for i in range(250)]
        right.reverse()
        self.assertEqual(right, list(range(150, 400)))
        self.assertEqual(list(d), list(range(50, 150))) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:20,代碼來源:test_deque.py

示例4: test_basics

# 需要導入模塊: from collections import deque [as 別名]
# 或者: from collections.deque import __init__ [as 別名]
def test_basics(self):
        d = deque(xrange(100))
        d.__init__(xrange(100, 200))
        for i in xrange(200, 400):
            d.append(i)
        for i in reversed(xrange(-200, 0)):
            d.appendleft(i)
        self.assertEqual(list(d), range(-200, 400))
        self.assertEqual(len(d), 600)

        left = [d.popleft() for i in xrange(250)]
        self.assertEqual(left, range(-200, 50))
        self.assertEqual(list(d), range(50, 400))

        right = [d.pop() for i in xrange(250)]
        right.reverse()
        self.assertEqual(right, range(150, 400))
        self.assertEqual(list(d), range(50, 150)) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:20,代碼來源:test_deque.py

示例5: __init__

# 需要導入模塊: from collections import deque [as 別名]
# 或者: from collections.deque import __init__ [as 別名]
def __init__(self, deque, result):
        self.deque = deque
        self.result = result 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:5,代碼來源:test_deque.py


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