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


Python pyrsistent.plist函数代码示例

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


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

示例1: test_iterable

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

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

示例2: decode

def decode(obj):
    if isinstance(obj, ExtType):
        if obj.code == TYPE_PSET:
            unpacked_data = unpackb(obj.data,
                                    use_list=False,
                                    encoding='utf-8')
            return pset(decode(item) for item in unpacked_data)
        if obj.code == TYPE_PLIST:
            unpacked_data = unpackb(obj.data,
                                    use_list=False,
                                    encoding='utf-8')
            return plist(decode(item) for item in unpacked_data)
        if obj.code == TYPE_PBAG:
            unpacked_data = unpackb(obj.data,
                                    use_list=False,
                                    encoding='utf-8')
            return pbag(decode(item) for item in unpacked_data)
        module_name, class_name, *data = unpackb(obj.data,
                                                 use_list=False,
                                                 encoding='utf-8')
        cls = getattr(sys.modules[module_name],
                      class_name)
        return cls(*(decode(item) for item in data))
    if isinstance(obj, tuple):
        return pvector(decode(item) for item in obj)
    if isinstance(obj, dict):
        new_dict = dict()
        for key in obj.keys():
            new_dict[decode(key)] = decode(obj[key])
        return pmap(new_dict)
    return obj
开发者ID:tlvu,项目名称:mochi,代码行数:31,代码来源:actor.py

示例3: no_interesctions

def no_interesctions(point_map):
    """Finds all of the graph edges such that all nodes are connected and no
    edges 'intersect' on the 2d plane"""
    all_edges = pset([s(anchor, search)
                      for anchor in point_map.keys()
                      for search in point_map.keys()
                      if anchor != search])
    edges_by_distance = sorted(plist(all_edges), key=lambda y: edge_distance(y, point_map))

    edges = []
    for edge in edges_by_distance:
        pair_a = edge_to_pair(edge, point_map)
        if not any([find_affine_intersection(pair_a, edge_to_pair(y, point_map)) for y in edges]):
            edges.append(edge)

    return edges
开发者ID:daStrauss,项目名称:puzzles,代码行数:16,代码来源:graphs.py

示例4: test_instantiate_large_list

def test_instantiate_large_list():
    assert plist(range(1000)).first == 0
开发者ID:ClusterHQ,项目名称:pyrsistent,代码行数:2,代码来源:list_test.py

示例5: test_rest_return_self_on_empty_list

def test_rest_return_self_on_empty_list():
    assert plist().rest is plist()
开发者ID:ClusterHQ,项目名称:pyrsistent,代码行数:2,代码来源:list_test.py

示例6: test_first_and_rest

def test_first_and_rest():
    pl = plist([1, 2])
    assert pl.first == 1
    assert pl.rest.first == 2
    assert pl.rest.rest is plist()
开发者ID:ClusterHQ,项目名称:pyrsistent,代码行数:5,代码来源:list_test.py

示例7: test_slicing_take_out_of_range

def test_slicing_take_out_of_range():
    assert plist([1, 2, 3])[:20] == plist([1, 2, 3])
开发者ID:ClusterHQ,项目名称:pyrsistent,代码行数:2,代码来源:list_test.py

示例8: test_indexing

def test_indexing():
    assert plist([1, 2, 3])[2] == 3
    assert plist([1, 2, 3])[-1] == 3
开发者ID:ClusterHQ,项目名称:pyrsistent,代码行数:3,代码来源:list_test.py

示例9: test_index_out_of_range

def test_index_out_of_range():
    with pytest.raises(IndexError):
        plist([1, 2])[2]

    with pytest.raises(IndexError):
        plist([1, 2])[-3]
开发者ID:ClusterHQ,项目名称:pyrsistent,代码行数:6,代码来源:list_test.py

示例10: test_supports_weakref

def test_supports_weakref():
    import weakref
    weakref.ref(plist())
    weakref.ref(plist([1, 2]))
开发者ID:ClusterHQ,项目名称:pyrsistent,代码行数:4,代码来源:list_test.py

示例11: test_inequality

def test_inequality():
    assert plist([1, 2]) != plist([1, 3])
    assert plist([1, 2]) != plist([1, 2, 3])
    assert plist() != plist([1, 2, 3])
开发者ID:ClusterHQ,项目名称:pyrsistent,代码行数:4,代码来源:list_test.py

示例12: test_remove_missing_element

def test_remove_missing_element():
    with pytest.raises(ValueError):
        plist([1, 2]).remove(3)

    with pytest.raises(ValueError):
        plist().remove(2)
开发者ID:ClusterHQ,项目名称:pyrsistent,代码行数:6,代码来源:list_test.py

示例13: test_mcons

def test_mcons():
    assert plist([1, 2]).mcons([3, 4]) == plist([4, 3, 1, 2])
开发者ID:ClusterHQ,项目名称:pyrsistent,代码行数:2,代码来源:list_test.py

示例14: test_remove

def test_remove():
    assert plist([1, 2, 3, 2]).remove(2) == plist([1, 3, 2])
    assert plist([1, 2, 3]).remove(1) == plist([2, 3])
    assert plist([1, 2, 3]).remove(3) == plist([1, 2])
开发者ID:ClusterHQ,项目名称:pyrsistent,代码行数:4,代码来源:list_test.py

示例15: test_split_empty_list

def test_split_empty_list():
    left_list, right_list = plist().split(2)
    assert left_list == plist()
    assert right_list == plist()
开发者ID:ClusterHQ,项目名称:pyrsistent,代码行数:4,代码来源:list_test.py


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