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): """ 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