arokem / python-matlab-bridge

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

Matlab error messages on run_code hard to debug #239

Open brunobeltran opened 8 years ago

brunobeltran commented 8 years ago

This is a fix that would greatly improve things like matlab_kernel. Could we (maybe only when requested by a flag) pass the matlab code to be executed to matlab in a line-by-line fashion? That way, if you have a 30 line script in a Jupyter notebook cell and you get back an "Index exceeds matrix dimensions" error, you can check which line caused the error?

As it stands, the fastest way to debug this kind of thing is to bisect the script by manually commenting out chunks of it at a time, which is pretty miserable. I could easily implement this if you like the idea but have no time.

To reproduce bug:

m = Matlab()
m.start()
m.run_code("""
a = 3;
% many lines of code
a(2);
% many more lines of code
""")
lrq3000 commented 5 years ago

I think this would be an amazing idea! No other bridge is doing that currently, and although this library is I think the easiest to debug (thanks to the extensive set of infos returned as a dict instead of failing with an exception), here with a step-by-step debugger it would be even better! This would certainly be a killer feature :D