Пример #1
0
def NanMap(nan_map, strict=False):
    return VariableTransformer(itemmap(
        lambda tup:
        (tup[0],
         Uncensor(
             Identity(tup[0]),
             Identity(tup[1])
             if isinstance(tup[1], string_types) else Constant(tup[1]))),
        nan_map),
                               strict=strict)
 def test_itemmap(self):
     D, kw = self.D, self.kw
     assert itemmap(reversed, D({1: 2, 2: 4}), **kw) == D({2: 1, 4: 2})
Пример #3
0
 def test_itemmap(self):
     D, kw = self.D, self.kw
     assert itemmap(reversed, D({1: 2, 2: 4}), **kw) == D({2: 1, 4: 2})
Пример #4
0
Файл: map.py Проект: tek/tryp.py
 def map(self, f: Callable[[Tuple[A, B]], Tuple[C, D]]) -> 'Map[C, D]':
     return Map(dicttoolz.itemmap(f, self))
Пример #5
0
def enrich_dict_immutable(dic):
    is_positive = lambda v: v >= 0
    filtered = dicttoolz.keyfilter(is_positive, dic)
    return dicttoolz.itemmap(_even_bar, filtered)
Пример #6
0
def test_itemmap():
    assert itemmap(reversed, {1: 2, 2: 4}) == {2: 1, 4: 2}
Пример #7
0
def test_environ():
    # See: https://github.com/pytoolz/cytoolz/issues/127
    assert keymap(identity, os.environ) == os.environ
    assert valmap(identity, os.environ) == os.environ
    assert itemmap(identity, os.environ) == os.environ
Пример #8
0
 def map(self, f: Callable[[A, B], Tuple[C, D]]) -> 'Map[C, D]':
     wrap = lambda a: f(*a)
     return Map(dicttoolz.itemmap(wrap, self))
Пример #9
0
 def level_to_name(self, level):
     """菜单层级转换为菜单名称"""
     return itemmap(reversed, self.menu_name_maps)[level]
Пример #10
0
def test_itemmap():
    assert itemmap(reversed, {1: 2, 2: 4}) == {2: 1, 4: 2}