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

pymatbridge returns unwritable array #248

Open Jvanschoubroeck opened 7 years ago

Jvanschoubroeck commented 7 years ago

I am using MATLAB_R2014b, pymatbridge 0.5.2 35_0, python 3.5 and Jupyter Notebook as interpreter. When calling a function in MATLAB using mlab.run_func the result is correctly computed and as following:

{'result': array([[ 4.86617840e+02, 7.13175750e-01, 5.70737308e-01, ... 1.14817386e-07, 1.14092193e-07, 1.17941819e-07]]), 'content': {'figures': [], 'datadir': '/private/tmp/MatlabData/', 'stdout': '[\x08Warning: Function isrow has the same name as a MATLAB builtin. We suggest you\nrename the function to avoid a potential name conflict.]\x08 \n[\x08> In path at 109\n In addpath at 86\n In pymat_eval at 27\n In matlabserver at 24]\x08 \n'}, 'success': True}

In a specific case, while not changing anything, the result returned is a non-writable array:

>>>['result'].flags.writable
False

When overwriting the flag to True using ['result'].flags.writeable = True I do not get the same error. And the program performs as all other tried instances. From Numpy I read: WRITEABLE can only be set True if the array owns its own memory or the ultimate owner of the memory exposes a writeable buffer interface or is a string.