• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pyrsistent.pdeque函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_construction_with_maxlen

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


示例17: test_pickling

def test_pickling():
    input = pdeque([1, 2, 3], maxlen=5)
    output = pickle.loads(pickle.dumps(input, -1))

    assert output == input
    assert output.maxlen == input.maxlen
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:6,代码来源:deque_test.py


示例18: test_remove

def test_remove():
    assert pdeque([1, 2, 3, 4]).remove(2) == pdeque([1, 3, 4])
    assert pdeque([1, 2, 3, 4]).remove(4) == pdeque([1, 2, 3])

    # Right list must be reversed before removing element
    assert pdeque([1, 2, 3, 3, 4, 5, 4, 6]).remove(4) == pdeque([1, 2, 3, 3, 5, 4, 6])
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:6,代码来源:deque_test.py


示例19: test_slicing

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


示例20: test_remove_element_missing

def test_remove_element_missing():
    with pytest.raises(ValueError):
        pdeque().remove(2)

    with pytest.raises(ValueError):
        pdeque([1, 2, 3]).remove(4)
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:6,代码来源:deque_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyrsistent.plist函数代码示例发布时间:2022-05-27
下一篇:
Python pyrsistent.pbag函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap