def run_func ( self , func_path , * func_args , * * kwargs ) : if not self . started : raise ValueError ( 'Session not started, use start()' ) nargout = kwargs . pop ( 'nargout' , 1 ) func_args += tuple ( item for pair in zip ( kwargs . keys ( ) , kwargs . values ( ) ) for item in pair ) dname = os . path . dirname ( func_path ) fname = os . path . basename ( func_path ) func_name , ext = os . path . splitext ( fname ) if ext and not ext == '.m' : raise TypeError ( 'Need to give path to .m file' ) return self . _json_response ( cmd = 'eval' , func_name = func_name , func_args = func_args or '' , dname = dname , nargout = nargout )
is there any wrapper that can ensure to use matlab's functions in python
Run a function in Matlab and return the result .
def run_func(self, func_path, *func_args, **kwargs):
        """Run a function in Matlab and return the result.

        Parameters
        ----------
        func_path: str
            Name of function to run or a path to an m-file.
        func_args: object, optional
            Function args to send to the function.
        nargout: int, optional
            Desired number of return arguments.
        kwargs:
            Keyword arguments are passed to Matlab in the form [key, val] so
            that matlab.plot(x, y, '--', LineWidth=2) would be translated into
            plot(x, y, '--', 'LineWidth', 2)

        Returns
        -------
        Result dictionary with keys: 'message', 'result', and 'success'
        """
        if not self.started:
            raise ValueError('Session not started, use start()')

        nargout = kwargs.pop('nargout', 1)
        func_args += tuple(item for pair in zip(kwargs.keys(), kwargs.values())
                           for item in pair)
        dname = os.path.dirname(func_path)
        fname = os.path.basename(func_path)
        func_name, ext = os.path.splitext(fname)
        if ext and not ext == '.m':
            raise TypeError('Need to give path to .m file')
        return self._json_response(cmd='eval',
                                   func_name=func_name,
                                   func_args=func_args or '',
                                   dname=dname,
                                   nargout=nargout)