[
        {
            'self': [1, 2, 3, 4, 5],
            'f': lambda x: x < 4,
            'assert': lambda ret: list(ret)  == [1, 2, 3]
         }
    ]
162887
def TakeWhile(self: dict, f):
    
    if is_to_destruct(f):
        f = destruct_func(f)

    for e in self.items():
        if not f(e):
            break
        yield e
171078
def lists(self, value, key=None):
        
        results = map(lambda x: x[value], self._items)

        return list(results)
39809
def _where(self, **kwargs):
        ''''''
        out = self
        for k,v in kwargs.items():
            out = out.where(k, lambda i:i==v)
        return out
656694
def is_dicteq(dict1_, dict2_, almosteq_ok=True, verbose_err=True):
    
    import utool as ut
    assert len(dict1_) == len(dict2_), 'dicts are not of same length'
    try:
        for (key1, val1), (key2, val2) in zip(dict1_.items(), dict2_.items()):
            assert key1 == key2, 'key mismatch'
            assert type(val1) == type(val2), 'vals are not same type'
            if HAVE_NUMPY and np.iterable(val1):
                if almosteq_ok and ut.is_float(val1):
                    assert np.all(ut.almost_eq(val1, val2)), 'float vals are not within thresh'
                else:
                    assert all([np.all(x1 == x2) for (x1, x2) in zip(val1, val2)]), 'np vals are different'
            elif isinstance(val1, dict):
                is_dicteq(val1, val2, almosteq_ok=almosteq_ok, verbose_err=verbose_err)
            else:
                assert val1 == val2, 'vals are different'
    except AssertionError as ex:
        if verbose_err:
            ut.printex(ex)
        return False
    return True
1063222
def CB(self):
        '''
        

        '''
        try:
            return self._CB
        except AttributeError:
            pass
        self._CB = [self.C, self.B]
        return self._CB
1220126
def list_of(cls):
    
    return lambda l: isinstance(l, list) and all(isinstance(x, cls) for x in l)
613430
def _tupleCompare(tuple1, ineq, tuple2,
                 eq=lambda a,b: (a==b),
                 ander=AND,
                 orer=OR):
    

    orholder = []
    for limit in range(len(tuple1)):
        eqconstraint = [
            eq(elem1, elem2) for elem1, elem2 in zip(tuple1, tuple2)[:limit]]
        ineqconstraint = ineq(tuple1[limit], tuple2[limit])
        orholder.append(ander(*(eqconstraint + [ineqconstraint])))
    return orer(*orholder)
760246
def ensure_list(iterable: Iterable[A]) -> List[A]:
    
    if isinstance(iterable, list):
        return iterable
    else:
        return list(iterable)
588571
def p_const_list(self, p):
        ''' '''
        p[0] = ast.ConstList(list(p[2]), p.lineno(1))
1306013
def p_argument_list(self, p):
        
        if len(p) == 2:
            p[0] = [p[1]]
        else:
            p[1].append(p[3])
            p[0] = p[1]
1144891
def p_ret(p):
    
    if len(p) == 2:
        p[0] = node.expr_list([p[1]])
    elif len(p) == 3:
        p[0] = node.expr_list([])
    elif len(p) == 4:
        assert isinstance(p[2], node.expr_list)
        p[0] = p[2]
    else:
        assert 0
    for ident in p[0]:
        ident.props = "F"
1163906
def Then5(self, f, arg1, arg2, arg3, arg4, *args, **kwargs):
        
        args = (arg1, arg2, arg3, arg4) + args
        return self.ThenAt(5, f, *args, **kwargs)
371106
def listify(p:OptListOrItem=None, q:OptListOrItem=None):
    ""
    if p is None: p=[]
    elif isinstance(p, str):          p = [p]
    elif not isinstance(p, Iterable): p = [p]
    #Rank 0 tensors in PyTorch are Iterable but don't have a length.
    else:
        try: a = len(p)
        except: p = [p]
    n = q if type(q)==int else len(p) if q is None else len(q)
    if len(p)==1: p = p * n
    assert len(p)==n, f'List len mismatch ({len(p)} vs {n})'
    return list(p)
138724
def listify(x, none_value=[]):
    """"""

    if isinstance(x, list):
        return x
    elif isinstance(x, tuple):
        return list(x)
    elif x is None:
        return none_value
    else:
        return [x]
1050792
def _(f, x):
    
    return {k: v for k, v in x.items() if f(k, v)}
1167563
def p_arg_list(p):
    
    if len(p) == 2:
        p[0] = node.expr_list([p[1]])
    elif len(p) == 4:
        p[0] = p[1]
        p[0].append(p[3])
    else:
        assert 0
    assert isinstance(p[0], node.expr_list)
1204277
def group_by_impl(func, sequence):
    
    result = {}
    for element in sequence:
        if result.get(func(element)):
            result.get(func(element)).append(element)
        else:
            result[func(element)] = [element]
    return six.viewitems(result)