How to use the siuba.siu.Lazy function in siuba

To help you get started, we’ve selected a few siuba examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github machow / siuba / siuba / dply / verbs.py View on Github external
def create_pipe_call(source, *args, **kwargs):
    first, *rest = args
    return Pipeable(Call(
            "__call__",
            strip_symbolic(source),
            strip_symbolic(first),
            *(Lazy(strip_symbolic(x)) for x in rest),
            **{k: Lazy(strip_symbolic(v)) for k,v in kwargs.items()}
            ))
github machow / siuba / siuba / dply / verbs.py View on Github external
def _case_when(__data, cases):
    if not isinstance(cases, dict):
        raise Exception("Cases must be a dictionary")
    dict_entries = dict((strip_symbolic(k), strip_symbolic(v)) for k,v in cases.items())
    cases_arg = Lazy(DictCall("__call__", dict, dict_entries))
    return create_sym_call(case_when, __data, cases_arg)
github machow / siuba / siuba / sql / verbs.py View on Github external
def shape_call(
            self,
            call, window = True, str_accessors = False,
            verb_name = None, arg_name = None,
            ):
        # TODO: error if mutate receives a literal value?
        # TODO: dispatch_cls currently unused
        if str_accessors and isinstance(call, str):
            # verbs that can use strings as accessors, like group_by, or
            # arrange, need to convert those strings into a getitem call
            return str_to_get_item_call(call)
        elif isinstance(call, sql.elements.ColumnClause):
            return Lazy(call)
        elif not isinstance(call, Call):
            # verbs that use literal strings, need to convert them to a call
            # that returns a sqlalchemy "literal" object
            return Lazy(sql.literal(call))

        # set up locals funcs dict
        f_dict1 = self.funcs['scalar']
        f_dict2 = self.funcs['window' if window else 'aggregate']

        funcs = {**f_dict1, **f_dict2}

        # determine dispatch class
        cls_name = 'window' if window else 'aggregate'
        dispatch_cls = self.dispatch_cls[cls_name]

        call_shaper = CallTreeLocal(
github machow / siuba / siuba / dply / verbs.py View on Github external
def create_pipe_call(source, *args, **kwargs):
    first, *rest = args
    return Pipeable(Call(
            "__call__",
            strip_symbolic(source),
            strip_symbolic(first),
            *(Lazy(strip_symbolic(x)) for x in rest),
            **{k: Lazy(strip_symbolic(v)) for k,v in kwargs.items()}
            ))
github machow / siuba / siuba / sql / verbs.py View on Github external
self,
            call, window = True, str_accessors = False,
            verb_name = None, arg_name = None,
            ):
        # TODO: error if mutate receives a literal value?
        # TODO: dispatch_cls currently unused
        if str_accessors and isinstance(call, str):
            # verbs that can use strings as accessors, like group_by, or
            # arrange, need to convert those strings into a getitem call
            return str_to_get_item_call(call)
        elif isinstance(call, sql.elements.ColumnClause):
            return Lazy(call)
        elif not isinstance(call, Call):
            # verbs that use literal strings, need to convert them to a call
            # that returns a sqlalchemy "literal" object
            return Lazy(sql.literal(call))

        # set up locals funcs dict
        f_dict1 = self.funcs['scalar']
        f_dict2 = self.funcs['window' if window else 'aggregate']

        funcs = {**f_dict1, **f_dict2}

        # determine dispatch class
        cls_name = 'window' if window else 'aggregate'
        dispatch_cls = self.dispatch_cls[cls_name]

        call_shaper = CallTreeLocal(
                funcs,
                call_sub_attr = self.call_sub_attr,
                dispatch_cls = dispatch_cls,
                result_cls = self.result_cls