arokem / python-matlab-bridge

A simple Python => MATLAB(R) interface and a matlab_magic for ipython
BSD 2-Clause "Simplified" License
335 stars 96 forks source link

Error pymatbridge: 'numpy.ndarray' object has no attribute 'todok' #254

Closed Trizali closed 7 years ago

Trizali commented 7 years ago

Hello

I'm trying to use a Cobra toolbox (in matlab code) in Jupyter Python notebook. But I have an error using pymatbrigde.

I can connect matlab using magic command

%load_ext pymatbridge
Starting MATLAB on ZMQ socket ipc:///tmp/pymatbridge-b2ebed23-7ab3-4368-8fec-652a366b03b5
Send 'exit' command to kill the server
...........MATLAB started and connected!

I also can read a model test:

import cobra.test
m = cobra.test.create_test_model("textbook")

But model_to_pymatbridge doesn't work, and I can't parse the matlab model object to python format.

from cobra.io.mat import model_to_pymatbridge
model_to_pymatbridge(model, variable_name="modelTest")

AttributeError Traceback (most recent call last)

in () 1 from cobra.io.mat import model_to_pymatbridge ----> 2 model_to_pymatbridge(m, variable_name="model") /home/user/anaconda2/lib/python2.7/site-packages/cobra/io/mat.pyc in model_to_pymatbridge(model, variable_name, matlab) 288 matlab = get_ipython().magics_manager.registry["MatlabMagics"].Matlab 289 model_info = create_mat_dict(model) **--> 290 S = model_info["S"].todok()** 291 model_info["S"] = 0 292 temp_S_name = "cobra_pymatbridge_temp_" + uuid4().hex **AttributeError: 'numpy.ndarray' object has no attribute 'todok'** I will be grateful for any help you can provide. Thank you in advance for your time.
arokem commented 7 years ago

This seems like an issue with the Cobra package. Looks like you've already reported it there: https://github.com/opencobra/cobrapy/issues/517, so I will close this here.