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


Python pyrsistent.m函数代码示例

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


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

示例1: test_supports_hash_and_equals

def test_supports_hash_and_equals():
    x = m(a=1, b=2, c=3)
    y = m(a=1, b=2, c=3)
    
    assert hash(x) == hash(y)
    assert x == y
    assert not (x != y)
开发者ID:alx-,项目名称:pyrsistent,代码行数:7,代码来源:map_test.py

示例2: test_unordered_messages

 def test_unordered_messages(self):
     messages = map(
         Message.new, [
             m(task_uuid='foo', task_level=[2]),
             m(task_uuid='foo', task_level=[1]),
         ])
     self.assertEqual(m(foo=[messages[1], messages[0]]), to_tasks(messages))
开发者ID:jml,项目名称:trial-eliot,代码行数:7,代码来源:test_parse.py

示例3: test_single_task

 def test_single_task(self):
     messages = map(
         Message.new, [
             m(task_uuid='foo', task_level=[1]),
             m(task_uuid='foo', task_level=[2]),
         ])
     self.assertEqual(m(foo=messages), to_tasks(messages))
开发者ID:jml,项目名称:trial-eliot,代码行数:7,代码来源:test_parse.py

示例4: test_no_task_level

 def test_no_task_level(self):
     messages = map(
         Message.new, [
             m(task_uuid='foo'),
             m(task_uuid='foo'),
         ])
     self.assertEqual(m(foo=messages), to_tasks(messages))
开发者ID:jml,项目名称:trial-eliot,代码行数:7,代码来源:test_parse.py

示例5: test_not_equal

def test_not_equal():
    x = m(a=1, b=2, c=3)
    y = m(a=1, b=2)

    assert x != y
    assert not (x == y)

    assert y != x
    assert not (y == x)
开发者ID:tobgu,项目名称:pyrsistent,代码行数:9,代码来源:map_test.py

示例6: __init__

    def __init__(self, timefunc=time.time):
        self.__data = m(products=m(), transactions=v(), summaries=v())

        self.__event_queue = Queue()    # sequential query execution
        self.__lock = Condition()       # passive waiting only
        self.__stop = Event()

        self.time = timefunc

        Thread(target=self.__run).start()
开发者ID:maaario,项目名称:persistent-store,代码行数:10,代码来源:db_core.py

示例7: test_update_with

def test_update_with():
    assert m(a=1).update_with(add, m(a=2, b=4)) == m(a=3, b=4)
    assert m(a=1).update_with(lambda l, r: l, m(a=2, b=4)) == m(a=1, b=4)

    def map_add(l, r):
        return dict(list(l.items()) + list(r.items()))

    assert m(a={'c': 3}).update_with(map_add, m(a={'d': 4})) == m(a={'c': 3, 'd': 4})
开发者ID:alx-,项目名称:pyrsistent,代码行数:8,代码来源:map_test.py

示例8: test_results_writer

def test_results_writer():
    """Does the results writer output what it should?"""
    results = m(episode=v(0, 1, 2), step_count=v(12, 22, 11))
    output_path = os.path.join(os.getcwd(), 'results.txt')
    results_descriptor = ResultsDescriptor(2, output_path, ['episode', 'step_count'])
    initialize_results(results_descriptor)
    write_results(results, results_descriptor)
    results_check = read_results(output_path)
    assert numpy.array_equal(results_check, numpy.array([[0., 12.], [1., 22.], [2., 11.]]))
    new_results = m(episode=v(3), step_count=v(12.33))
    write_results(new_results, results_descriptor)
    new_results_check = read_results(output_path)
    assert numpy.array_equal(new_results_check, numpy.array([[0., 12.], [1., 22.], [2., 11.], [3., 12.33]]))
开发者ID:xanderdunn,项目名称:options,代码行数:13,代码来源:test_results_writer.py

示例9: __init__

    def __init__(self, pipe = None, new_stack = None):
        if not pipe:
            stack = v(m())
            dump = m()
        else:
            stack = pipe.stack
            dump = pipe.dump

        if new_stack:
            stack = new_stack

        self.stack = stack
        self.dump = dump
开发者ID:phizaz,项目名称:seeding-strategy-ssl,代码行数:13,代码来源:pipe.py

示例10: test_multiple_tasks

 def test_multiple_tasks(self):
     messages = map(
         Message.new, [
             m(task_uuid='foo', task_level=[1]),
             m(task_uuid='bar', task_level=[1]),
             m(task_uuid='foo', task_level=[2]),
         ])
     self.assertEqual(
         m(
             foo=[messages[0], messages[2]],
             bar=[messages[1]],
         ),
         to_tasks(messages))
开发者ID:jml,项目名称:trial-eliot,代码行数:13,代码来源:test_parse.py

示例11: test_mutant_decorator

def test_mutant_decorator():
    @mutant
    def fn(a_list, a_dict):
        assert a_list == v(1, 2, 3)
        assert isinstance(a_dict, type(m()))
        assert a_dict == {'a': 5}

        return [1, 2, 3], {'a': 3}

    pv, pm = fn([1, 2, 3], a_dict={'a': 5})

    assert pv == v(1, 2, 3)
    assert pm == m(a=3)
    assert isinstance(pm, type(m()))
开发者ID:ClusterHQ,项目名称:pyrsistent,代码行数:14,代码来源:freeze_test.py

示例12: test_various_iterations

def test_various_iterations():
    assert set(['a', 'b']) == set(m(a=1, b=2))
    assert ['a', 'b'] == sorted(m(a=1, b=2).keys())
    assert isinstance(m().keys(), PVector)

    assert set([1, 2]) == set(m(a=1, b=2).itervalues())
    assert [1, 2] == sorted(m(a=1, b=2).values())
    assert isinstance(m().values(), PVector)

    assert set([('a', 1), ('b', 2)]) == set(m(a=1, b=2).iteritems())
    assert set([('a', 1), ('b', 2)]) == set(m(a=1, b=2).items())
    assert isinstance(m().items(), PVector)
开发者ID:alx-,项目名称:pyrsistent,代码行数:12,代码来源:map_test.py

示例13: start_configuration

def start_configuration():
    """
    Creates the initial PMap that will be passed down the pipeline

    :return:
    """
    return pyr.m()
开发者ID:RedHatQE,项目名称:pong,代码行数:7,代码来源:configuration.py

示例14: test_evolver_remove_element_not_present

def test_evolver_remove_element_not_present():
    e = m(a=1000, b=2000).evolver()

    with pytest.raises(KeyError) as error:
        del e['c']

    assert str(error.value) == "'c'"
开发者ID:alx-,项目名称:pyrsistent,代码行数:7,代码来源:map_test.py

示例15: __init__

    def __init__(self, x_size, y_size, tile_size):
        self.size = pyrsistent.m(x=x_size, y=y_size)

        tile_types = [
            tile.GrassTile,
            tile.GrassTile,
            tile.WaterTile,
        ]

        self.tiles = {
            vector.Vector2(x, y): random.choice(tile_types)()
            for x in range(x_size)
            for y in range(y_size)
        }

        self.sprite_batch = multimedia.SpriteBatch()

        self.sprites = pyrsistent.pmap({
            coord: multimedia.Sprite(
                self.tiles[coord].image,
                vector.Vector2(
                    x=coord.x*tile_size,
                    y=coord.y*tile_size,
                ),
                batch=self.sprite_batch,
            )
            for coord in self.tiles
        })
开发者ID:kjwilcox,项目名称:tactics,代码行数:28,代码来源:tilemap.py


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