本文整理汇总了Python中pyrsistent.v.evolver函数的典型用法代码示例。如果您正苦于以下问题:Python evolver函数的具体用法?Python evolver怎么用?Python evolver使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了evolver函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_pvectors_produced_from_the_same_evolver_do_not_interfere
def test_pvectors_produced_from_the_same_evolver_do_not_interfere(pvector):
original_list = list(range(40))
v = pvector(original_list)
e = v.evolver()
e.extend([1, 2, 3])
e[2] = 20
e[35] = 350
v1 = e.persistent()
v1_expected = original_list + [1, 2, 3]
v1_expected[2] = 20
v1_expected[35] = 350
e.extend([-1, -2, -3])
e[3] = -30
e[36] = -360
v2 = e.persistent()
v2_expected = v1_expected + [-1, -2, -3]
v2_expected[3] = -30
v2_expected[36] = -360
assert list(v1) == v1_expected
assert list(v2) == v2_expected
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:25,代码来源:vector_test.py
示例2: test_evolver_simple_update_in_tree
def test_evolver_simple_update_in_tree(pvector):
v = pvector(range(35))
e = v.evolver()
e[10] = -10
assert e[10] == -10
assert e.persistent()[10] == -10
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:7,代码来源:vector_test.py
示例3: test_evolver_extend
def test_evolver_extend(pvector):
v = pvector([1000])
e = v.evolver()
e.extend([2000, 3000])
e[2] = 20000
assert list(e.persistent()) == [1000, 2000, 20000]
assert list(v) == [1000]
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:8,代码来源:vector_test.py
示例4: test_evolver_simple_update_just_outside_vector
def test_evolver_simple_update_just_outside_vector(pvector):
v = pvector()
e = v.evolver()
e[0] = 1
assert e[0] == 1
assert e.persistent()[0] == 1
assert len(v) == 0
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:8,代码来源:vector_test.py
示例5: test_evolver_simple_update_in_tail
def test_evolver_simple_update_in_tail(pvector):
v = pvector(range(35))
e = v.evolver()
e[33] = -33
assert e[33] == -33
assert e.persistent()[33] == -33
assert v[33] == 33
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:8,代码来源:vector_test.py
示例6: test_evolver_assign_and_read_with_negative_indices
def test_evolver_assign_and_read_with_negative_indices(pvector):
v = pvector([1, 2, 3])
e = v.evolver()
e[-1] = 4
e.extend([11, 12, 13])
e[-1] = 33
assert e[-1] == 33
assert list(e.persistent()) == [1, 2, 4, 11, 12, 33]
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:9,代码来源:vector_test.py
示例7: test_evolver_append
def test_evolver_append(pvector):
v = pvector()
e = v.evolver()
e.append(1000)
assert e[0] == 1000
e[0] = 2000
assert e[0] == 2000
assert list(e.persistent()) == [2000]
assert list(v) == []
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:10,代码来源:vector_test.py
示例8: test_no_dependencies_between_evolvers_from_the_same_pvector
def test_no_dependencies_between_evolvers_from_the_same_pvector(pvector):
original_list = list(range(40))
v = pvector(original_list)
e1 = v.evolver()
e2 = v.evolver()
e1.extend([1, 2, 3])
e1[2] = 20
e1[35] = 350
e2.extend([-1, -2, -3])
e2[2] = -20
e2[35] = -350
e1_expected = original_list + [1, 2, 3]
e1_expected[2] = 20
e1_expected[35] = 350
assert list(e1.persistent()) == e1_expected
e2_expected = original_list + [-1, -2, -3]
e2_expected[2] = -20
e2_expected[35] = -350
assert list(e2.persistent()) == e2_expected
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:23,代码来源:vector_test.py
示例9: test_evolver_multi_level_multi_update_in_tree
def test_evolver_multi_level_multi_update_in_tree(pvector):
# This test is mostly to detect memory/ref count issues in the native implementation
v = pvector(range(3500))
e = v.evolver()
# Update differs between first and second time since the
# corresponding node will be marked as dirty the first time only.
e[10] = -10
e[11] = -11
e[10] = -1000
# Update in neighbour node
e[50] = -50
e[50] = -5000
# Update in node in other half of vector
e[3000] = -3000
e[3000] = -30000
# Before freezing
assert e[10] == -1000
assert e[11] == -11
assert e[50] == -5000
assert e[3000] == -30000
# Run a GC to provoke any potential misbehavior
import gc
gc.collect()
v2 = e.persistent()
assert v2[10] == -1000
assert v2[50] == -5000
assert v2[3000] == -30000
# Run a GC to provoke any potential misbehavior
gc.collect()
# After freezing
assert e[10] == -1000
assert e[11] == -11
assert e[50] == -5000
assert e[3000] == -30000
# Original stays the same
assert v[10] == 10
assert v[50] == 50
assert v[3000] == 3000
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:47,代码来源:vector_test.py
示例10: test_evolver_returns_itself_on_evolving_operations
def test_evolver_returns_itself_on_evolving_operations(pvector):
# Does this to be able to chain operations
v = pvector([1, 2])
assert v.evolver().append(3).extend([4, 5]).set(1, 6).persistent() == pvector([1, 6, 3, 4, 5])
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:4,代码来源:vector_test.py
示例11: test_evolver_with_no_updates_returns_same_pvector
def test_evolver_with_no_updates_returns_same_pvector(pvector):
v = pvector([1, 2])
assert v.evolver().persistent() is v
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:3,代码来源:vector_test.py
示例12: test_evolver_set_out_of_range
def test_evolver_set_out_of_range(pvector):
v = pvector([0])
e = v.evolver()
with pytest.raises(IndexError) as error:
e[10] = 1
assert str(error.value) == "Index out of range: 10"
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:6,代码来源:vector_test.py
示例13: test_evolver_deallocate_dirty_evolver
def test_evolver_deallocate_dirty_evolver(pvector):
# Ref count handling in native implementation
v = pvector(range(3220))
e = v.evolver()
e[10] = -10
e[3220] = -3220
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:6,代码来源:vector_test.py
示例14: test_evolver_no_update
def test_evolver_no_update(pvector):
# This is mostly a test against memory leaks in the C implementation
v = pvector(range(40))
assert v.evolver().persistent() == v
开发者ID:RichardFreeman,项目名称:pyrsistent,代码行数:5,代码来源:vector_test.py
注:本文中的pyrsistent.v.evolver函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论