def connect_to_matlab(): mlab = pymat.Matlab() mlab.start() npt.assert_(mlab.is_connected(), msg="connect_to_matlab(): Connection failed") return mlab
def connect_to_matlab(): mlab = pymat.Octave() if on_octave() else pymat.Matlab(log=True) mlab.start() npt.assert_(mlab.is_connected(), msg="connect_to_matlab(): Connection failed") return mlab
def __init__(self, shell, matlab='matlab', maxtime=60, pyconverter=np.asarray, cache_display_data=False): """ Parameters ---------- shell : IPython shell matlab : str The system call to start a matlab session. Allows you to choose a particular version of matlab if you want maxtime : float The maximal time to wait for responses for matlab (in seconds). Default: 10 seconds. pyconverter : callable To be called on matlab variables returning into the ipython namespace cache_display_data : bool If True, the published results of the final call to R are cached in the variable 'display_cache'. """ super(MatlabMagics, self).__init__(shell) self.cache_display_data = cache_display_data self.Matlab = pymat.Matlab(matlab, maxtime=maxtime) self.Matlab.start() self.pyconverter = pyconverter
def __init__(self, shell, matlab='matlab', maxtime=60, pyconverter=np.asarray): """ Parameters ---------- shell : IPython shell matlab : str The system call to start a matlab session. Allows you to choose a particular version of matlab if you want maxtime : float The maximal time to wait for responses for matlab (in seconds). Default: 10 seconds. pyconverter : callable To be called on matlab variables returning into the ipython namespace """ super(MatlabMagics, self).__init__(shell) if 'octave' in matlab.lower(): self.Matlab = pymat.Octave(matlab, maxtime=maxtime) else: self.Matlab = pymat.Matlab(matlab, maxtime=maxtime) self.Matlab.start() self.pyconverter = pyconverter
def __init__(self, shell, matlab='matlab', pyconverter=np.asarray, **kwargs): """ Parameters ---------- shell : IPython shell matlab : str The system call to start a matlab session. Allows you to choose a particular version of matlab if you want pyconverter : callable To be called on matlab variables returning into the ipython namespace kwargs: additional key-word arguments to pass to initialization of the Matlab/Octave process """ super(MatlabMagics, self).__init__(shell) if 'octave' in matlab.lower(): self.Matlab = pymat.Octave(matlab, **kwargs) else: self.Matlab = pymat.Matlab(matlab, **kwargs) self.Matlab.start() self.pyconverter = pyconverter
def __init__(self, cdata, camera_nb=0, camera_type='tomokth'): """Initializes a MATLAB/Octave session and other parameters""" self.path = os.path.join(_here, '_calibr') try: self.pymat = pymatbridge.Matlab() self.pylab.start() except: self.pymat = pymatbridge.Octave() self.pymat.start() self.pymat.run_code('addpath({})'.format(self.path)) if isinstance(cdata, CalibrationData): self.cdata = cdata else: raise ValueError('data must be an instance of CalibrationData') self.camera_nb = camera_nb self.camera_type = camera_type
journal = {Journal of Machine Learning Research}, year = {2014}, volume = {15}, pages = {2833-2868}, } """ import math import pymatbridge PYM_PATH = "/Users/canjo/src/PYMentropy/src/" LOG2 = math.log(2) INF = float('inf') M = pymatbridge.Matlab() M.start() class MatlabException(Exception): pass def matlabfunc(path, nargout): def f(*args): result_obj = M.run_func(path, *args, nargout=nargout) if result_obj['success']: return result_obj['result'] else: raise MatlabException(result_obj)