def add_regularizer(self, proxfun, **kwargs):
        """
        Add a regularizer from the operators module to the list of objectives

        Parameters
        ----------
        proxfun : string or function
            If a string, then it must be the name of a corresponding function in the `operators` module.
            If a function, then it must apply a proximal update given an initial point x0, momentum parameter
            rho, and optional arguments given in `**kwargs`.

        \\*\\*kwargs : keyword arguments
            Any optional arguments required for the given function

        """

        # if proxfun is a string, grab the corresponding function from operators.py
        if isinstance(proxfun, str):
            try:
                proxfun_name = proxfun.split(None, 1)[0]
                # Ignore everything after white space
                op = getattr(operators, proxfun_name)
                self.objectives.append(lambda theta, rho: op(theta.copy(), float(rho), **kwargs))

            except AttributeError as e:
                print(str(e) + '\n' + 'Could not find the function ' + proxfun + ' in the operators module!')

        # if proxfun is a function, add it as its own proximal operator
        elif hasattr(proxfun, '__call__'):
            self.objectives.append(lambda theta, rho: proxfun(theta.copy(), float(rho)))

        # type of proxfun must be a string or a function
        else:
            raise TypeError('The argument "proxfun" must be a string or a function!')
def add_regularizer ( self , proxfun , ** kwargs ) : if isinstance ( proxfun , str ) : try : proxfun_name = proxfun . split ( None , 1 ) [ 0 ] op = getattr ( operators , proxfun_name ) self . objectives . append ( lambda theta , rho : op ( theta . copy ( ) , float ( rho ) , ** kwargs ) ) except AttributeError as e : print ( str ( e ) + '\n' + 'Could not find the function ' + proxfun + ' in the operators module!' ) elif hasattr ( proxfun , '__call__' ) : self . objectives . append ( lambda theta , rho : proxfun ( theta . copy ( ) , float ( rho ) ) ) else : raise TypeError ( 'The argument "proxfun" must be a string or a function!' )
Add a regularizer from the operators module to the list of objectives

        Parameters
        ----------
        proxfun : string or function
            If a string, then it must be the name of a corresponding function in the `operators` module.
            If a function, then it must apply a proximal update given an initial point x0, momentum parameter
            rho, and optional arguments given in `**kwargs`.

        \\*\\*kwargs : keyword arguments
            Any optional arguments required for the given function