matlab2python icon indicating copy to clipboard operation
matlab2python copied to clipboard

TypeError: 'numpy.ndarray' object is not callable matlab2python

Open SDIdo opened this issue 4 years ago • 1 comments

Dear ebranlard, Thank you for making this amazing tool. We have almost everything converted out-of-the-box with minor bearable changes.

Issue: The recognizing of a matlab array or matrix is needed many times. Matlab2Python, currently, doesn't recognize and thus takes slicing as a function call. This probably makes it not recognize the index change that is needed as well.

Recreation:

test.m

x = [1:4,11:14];
y = x(1,1);
disp(y);

test.py

import numpy as np
x = np.array([np.arange(1,4+1),np.arange(11,14+1)])
y = x(1,1)
print(y)

y = x(1,1), at run, will cause the following error TypeError: 'numpy.ndarray' object is not callable

Will be glad for a fix or a direction towards what to change in the code.

Best Regards, SDido

SDIdo avatar Nov 24 '21 17:11 SDIdo

Hi @SDIdo,

Sorry for the late reply. Thanks for reporting this and for your nice and simple example.

Those are indeed hard to parse... So far I've updated them manually. I've been a bit away from this project for a while, so I wouldn't have any recommendations as to how to go about this. I would have to dive into the code, and possibly into the SMOP code. Your test case is definitely a good start.

ebranlard avatar Apr 06 '22 16:04 ebranlard