mrkrd / matlab_wrapper

Easy to use MATLAB wrapper for Python
GNU General Public License v3.0
78 stars 23 forks source link

problem with eval in matlab_wrapper and python #17

Closed AliBaheri closed 8 years ago

AliBaheri commented 8 years ago

Hi! I am running the following code: `def emin_epmgp(m,K,eta):'

global mtb    
if mtb == None:
    import matlab_wrapper
    mtb = matlab_wrapper.MatlabSession(matlab_root = "/Applications/MATLAB_R2014b.app")

try:
    mtb.put('K',0.5*(K+K.T))  # symetrize to avoid numerical inconsitencies
    mtb.put('m',m)
    mtb.put('eta',eta)
    mtb.eval("[e_min,Int_y,Probs_y,Int_eta] = emin_epmgp(m,K,eta)")
    e_min = mtb.get('e_min')
except:
    mtb.put('K',0.5*(K+K.T)+0.1*np.diag(np.ones(K.shape[0])))  # regularize in case of errors caused by K being singular
    mtb.put('m',m)
    mtb.put('eta',eta)
    mtb.eval("[e_min,Int_y,Probs_y,Int_eta] = emin_epmgp(m,K,eta)")
    e_min = mtb.get('e_min')
return e_min`

however, after running the following line: mtb.eval("[e_min,Int_y,Probs_y,Int_eta] = emin_epmgp(m,K,eta)")

I am facing with the following error: `RuntimeError Traceback (most recent call last)

in () ----> 1 mtb.eval("[e_min,Int_y,Probs_y,Int_eta] = emin_epmgp(m,K,eta)") /Users/ali/anaconda/lib/python2.7/site-packages/matlab_wrapper-0.9.5-py2.7.egg/matlab_wrapper/matlab_session.pyc in eval(self, expression) 172 173 ### Check for exceptions in MATLAB --> 174 mxresult = self._libeng.engGetVariable(self._ep, 'ERRSTR__') 175 176 error_string = self._libmx.mxArrayToString(mxresult) /Users/ali/anaconda/lib/python2.7/site-packages/matlab_wrapper-0.9.5-py2.7.egg/matlab_wrapper/matlab_session.pyc in error_check(result, func, arguments) 236 func=str(func), 237 result=str(result), --> 238 arguments=str(arguments) 239 )) 240 return result RuntimeError: MATLAB function <_FuncPtr object at 0x10f5ef7a0> failed () with arguments: (, 'ERRSTR__')` I really do not have idea to fix it. Clearly, the problem come from `eval`, but I am not able to debug it. PS: the issue is similar to this issue: https://github.com/mrkrd/matlab_wrapper/issues/11 But I could not find a solution. Thanks for your time and consideration.
mrkrd commented 8 years ago

Hi,

It looks that this problem originates in emin_epmgp and not matlab_wrapper.

My suggestions:

Marek

[1] https://github.com/mrkrd/matlab_wrapper/blob/master/CONTRIBUTING.rst