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})
def map(self, f: Callable[[Tuple[A, B]], Tuple[C, D]]) -> 'Map[C, D]': return Map(dicttoolz.itemmap(f, self))
def enrich_dict_immutable(dic): is_positive = lambda v: v >= 0 filtered = dicttoolz.keyfilter(is_positive, dic) return dicttoolz.itemmap(_even_bar, filtered)
def test_itemmap(): assert itemmap(reversed, {1: 2, 2: 4}) == {2: 1, 4: 2}
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
def map(self, f: Callable[[A, B], Tuple[C, D]]) -> 'Map[C, D]': wrap = lambda a: f(*a) return Map(dicttoolz.itemmap(wrap, self))
def level_to_name(self, level): """菜单层级转换为菜单名称""" return itemmap(reversed, self.menu_name_maps)[level]