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

Python pyrsistent.m函数代码示例

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

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



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


示例16: test_remove_non_existing_element_raises_key_error

def test_remove_non_existing_element_raises_key_error():
    m1 = m(a=1)

    with pytest.raises(KeyError) as error:
        m1.remove('b')

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


示例17: test_dot_access_of_non_existing_element_raises_attribute_error

def test_dot_access_of_non_existing_element_raises_attribute_error():
    m1 = m(a=10)

    with pytest.raises(AttributeError) as error:
        m1.b

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


示例18: iter_valid_plays_for_card

def iter_valid_plays_for_card(card, myself, others):
    """Iterate through a list of valid plays for the given card.

    The plays are only valid within the rules of the game. They don't pay
    attention to the current state. Thus, they might guess that a player has
    the Minister even though it has already been played.

    The order of iteration is irrelevant and not guaranteed to be stable.
    """
    play = m(card=card)
    if card in ('Priestess', 'Minister', 'Prince'):
        yield play
    elif card in ('Wizard',):
        yield play.set('target', myself)
        for target in others:
            yield play.set('target', target)
    elif card in ('Clown', 'Knight', 'General'):
        for target in others:
            yield play.set('target', target)
    else:
        for target in others:
            targeted = play.set('target', target)
            for card in CARDS:
                if card == 'Soldier':
                    continue
                yield targeted.set('guess', card)
开发者ID:jml,项目名称:pyhazard,代码行数:26,代码来源:_rules.py


示例19: test_evolver_simple_update

def test_evolver_simple_update():
    x = m(a=1000, b=2000)
    e = x.evolver()
    e['b'] = 3000

    assert e['b'] == 3000
    assert e.persistent()['b'] == 3000
    assert x['b'] == 2000
开发者ID:alx-,项目名称:pyrsistent,代码行数:8,代码来源:map_test.py


示例20: test_not_equal_to_dict

def test_not_equal_to_dict():
    x = m(a=1, b=2, c=3)
    y = dict(a=1, b=2, d=4)

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

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pyrsistent.pbag函数代码示例发布时间:2022-05-27
下一篇:
Python pyrsistent.freeze函数代码示例发布时间: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