当前位置: 首页>>代码示例>>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;未经允许,请勿转载。