I am porting some Matlab code to Python. In this code there are many instances of a large matrix being sliced in many different ways, eg M(2:45,13:18), M(:12,:), V(4), V(:27), etc. It is technically possible to convert this to numpy notation manually, by replacing the parentheses with square brackets and substracting 1 to all indices (except after :) but it is incredibly tedious and there is a very high probability that I will make a typo at some point.
I tried automating this but my grep/awk/parsing skills are not good enough. Is there a script out there that will do the job?
basicindexing is similar enough, indexing with lists/arrays, whatnumpydocs calladvancedindexing is different. You have to usenp.ix_to get similar 'block' indexing.V(:27)because it means nothing in MATLAB.