pymc4/utils.py
def biwrap(wrapper) -> Callable:
    """Allow for optional keyword arguments in lower level decoratrors.

    Notes
    -----
    Currently this is only used to wrap pm.Model to capture model runtime flags such as
    keep_auxiliary and keep_return. See pm.Model for all possible keyword parameters

    """

    @functools.wraps(wrapper)
    def enhanced(*args, **kwargs) -> Callable:

        # Check if decorated method is bound to a class
        is_bound_method = hasattr(args[0], wrapper.__name__) if args else False
        if is_bound_method:
            # If bound to a class, `self` will be an argument
            count = 1
        else:
            count = 0
        if len(args) > count:
            # If lower level decorator is not called user model will be an argument
            # fill in parameters and call pm.Model
            newfn = wrapper(*args, **kwargs)
            return newfn
        else:
            # If lower level decorator is called user model will not be passed in as an argument
            # prefill args and kwargs but do not call pm.Model
            newwrapper = functools.partial(wrapper, *args, **kwargs)
            return newwrapper

    return enhanced
Allow for optional keyword arguments in lower level decoratrors.

    Notes
    -----
    Currently this is only used to wrap pm.Model to capture model runtime flags such as
    keep_auxiliary and keep_return. See pm.Model for all possible keyword parameters

    
Allow for optional keyword arguments in lower level decoratrors.
Notes

Currently this is only used to wrap pm.Model to capture model runtime flags such as
keep_auxiliary and keep_return. See pm.Model for all possible keyword parameters
Allow for optional keyword arguments in lower level decoratrors . Notes Currently this is only used to wrap pm . Model to capture model runtime flags such as keep_auxiliary and keep_return . See pm . Model for all possible keyword parameters
def biwrap(wrapper) -> Callable:
    @functools.wraps(wrapper)
    def enhanced(*args, **kwargs) -> Callable:
        is_bound_method = hasattr(args[0], wrapper.__name__) if args else False
        if is_bound_method:
            count = 1
        else:
            count = 0
        if len(args) > count:
            newfn = wrapper(*args, **kwargs)
            return newfn
        else:
            newwrapper = functools.partial(wrapper, *args, **kwargs)
            return newwrapper
    return enhanced
def biwrap ( wrapper ) -> Callable : @ functools . wraps ( wrapper ) def enhanced ( * args , ** kwargs ) -> Callable : is_bound_method = hasattr ( args [ 0 ] , wrapper . __name__ ) if args else False if is_bound_method : count = 1 else : count = 0 if len ( args ) > count : newfn = wrapper ( * args , ** kwargs ) return newfn else : newwrapper = functools . partial ( wrapper , * args , ** kwargs ) return newwrapper return enhanced
Allow for optional keyword arguments in lower level decoratrors.
Allow for optional keyword arguments in lower level decoratrors .
"""Allow for optional keyword arguments in lower level decoratrors.

    Notes
    -----
    Currently this is only used to wrap pm.Model to capture model runtime flags such as
    keep_auxiliary and keep_return. See pm.Model for all possible keyword parameters

    """ # Check if decorated method is bound to a class # If bound to a class, `self` will be an argument # If lower level decorator is not called user model will be an argument # fill in parameters and call pm.Model # If lower level decorator is called user model will not be passed in as an argument # prefill args and kwargs but do not call pm.Model
wrapper