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


Python pyrsistent.pdeque函数代码示例

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


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

示例1: test_iterable

def test_iterable():
    """
    PDeques can be created from iterables even though they can't be len()
    hinted.
    """

    assert pdeque(iter("a")) == pdeque(iter("a"))
开发者ID:tobgu,项目名称:pyrsistent,代码行数:7,代码来源:deque_test.py

示例2: test_comparison

def test_comparison():
    small = pdeque([1, 2])
    large = pdeque([1, 2, 3])

    assert small < large
    assert large > small
    assert not small > large
    assert not large < small
    assert large != small

    # Not equal to other types
    assert small != [1, 2]
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:12,代码来源:deque_test.py

示例3: test_indexing

def test_indexing():
    assert pdeque([1, 2, 3])[0] == 1
    assert pdeque([1, 2, 3])[1] == 2
    assert pdeque([1, 2, 3])[2] == 3
    assert pdeque([1, 2, 3])[-1] == 3
    assert pdeque([1, 2, 3])[-2] == 2
    assert pdeque([1, 2, 3])[-3] == 1
开发者ID:tobgu,项目名称:pyrsistent,代码行数:7,代码来源:deque_test.py

示例4: test_indexing_out_of_range

def test_indexing_out_of_range():
    with pytest.raises(IndexError):
        pdeque([1, 2, 3])[-4]

    with pytest.raises(IndexError):
        pdeque([1, 2, 3])[3]

    with pytest.raises(IndexError):
        pdeque([2])[-2]
开发者ID:tobgu,项目名称:pyrsistent,代码行数:9,代码来源:deque_test.py

示例5: test_popleft

def test_popleft():
    x = pdeque([1, 2, 3, 4]).popleft()
    assert x.left == 2
    assert x.right == 4

    x = x.popleft()
    assert x.left == 3
    assert x.right == 4

    x = x.popleft()
    assert x.right == 4
    assert x.left == 4

    x = x.popleft()
    assert x == pdeque()

    x = pdeque([1, 2]).popleft()
    assert x == pdeque([2])

    x = x.popleft()
    assert x == pdeque()

    assert pdeque().append(1).popleft() == pdeque()
    assert pdeque().appendleft(1).popleft() == pdeque()
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:24,代码来源:deque_test.py

示例6: test_left_on_empty_deque

def test_left_on_empty_deque():
    with pytest.raises(IndexError):
        pdeque().left
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:3,代码来源:deque_test.py

示例7: test_pop_multiple

def test_pop_multiple():
    assert pdeque([1, 2, 3, 4]).pop(3) == pdeque([1])
    assert pdeque([1, 2]).pop(3) == pdeque()
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:3,代码来源:deque_test.py

示例8: test_literalish

def test_literalish():
    assert dq(1, 2, 3) == pdeque([1, 2, 3])
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:deque_test.py

示例9: test_hashing

def test_hashing():
    assert hash(pdeque([1, 2, 3])) == hash(pdeque().append(1).append(2).append(3))
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:deque_test.py

示例10: test_indexing_invalid_type

def test_indexing_invalid_type():
    with pytest.raises(TypeError) as e:
        pdeque([1, 2, 3])['foo']

    assert 'cannot be interpreted' in str(e)
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:5,代码来源:deque_test.py

示例11: test_count

def test_count():
    x = pdeque([1, 2, 3, 2, 1])
    assert x.count(1) == 2
    assert x.count(2) == 2
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:4,代码来源:deque_test.py

示例12: test_extendleft_with_maxlen

def test_extendleft_with_maxlen():
    assert pdeque([1, 2], maxlen=3).extendleft([3, 4]) == pdeque([4, 3, 1])
    assert pdeque([1, 2], maxlen=2).extendleft([3, 4]) == pdeque([4, 3])
    assert pdeque([], maxlen=2).extendleft([1, 2]) == pdeque([2, 1])
    assert pdeque([], maxlen=0).extendleft([1, 2]) == pdeque([])
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:5,代码来源:deque_test.py

示例13: test_extendleft

def test_extendleft():
    assert pdeque([2, 1]).extendleft([3, 4]) == pdeque([4, 3, 2, 1])
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:deque_test.py

示例14: test_extend_with_maxlen

def test_extend_with_maxlen():
    assert pdeque([1, 2], maxlen=3).extend([3, 4]) == pdeque([2, 3, 4])
    assert pdeque([1, 2], maxlen=2).extend([3, 4]) == pdeque([3, 4])
    assert pdeque([], maxlen=2).extend([1, 2]) == pdeque([1, 2])
    assert pdeque([], maxlen=0).extend([1, 2]) == pdeque([])
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:5,代码来源:deque_test.py

示例15: test_extend

def test_extend():
    assert pdeque([1, 2]).extend([3, 4]) == pdeque([1, 2, 3, 4])
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:2,代码来源:deque_test.py


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