Issue
Is it possible in IPython interactive console to show not only the row at which the error is originating but also the column?
For example in this script, I know that the problematic line is 934 but I have no way to find which statement generates the error since I don't know the column.
--> 934 dQ0 = (Knm0[u, :] + W0[u, u] - Knm0[u, ma]) - multiply((Kn0[u]), (Km0 + Kn0[u] - Km0[ma])) / s0
935 dQ1 = (Knm1[u, :] + W1[u, u] - Knm1[u, ma]) - multiply((Kn1[u]), (Km1 + Kn1[u] - Km1[ma])) / s1
936 dQ = d0 * dQ0 - d1 * dQ1
IndexError: invalid index to scalar variable.
Solution
Normally, the shortest way to debug these is simply this:
In [5]: %debug
(or just debug
if %automagic
is on). That drops you into the debugger where the failure occurred. Then you can dump the different objects i.e. Knm0
, Kn0
, etc. or try different pieces like Knm0[u,:]
and see which one throws the error, what the object looks like, etc.
In your case, it looks like you're trying to use slicing on something that's not array, like doing 245[0]
is not legal. So it's not as simple as which column is the problem - this line isn't the problem at all, it's mostly likely some line above that generated the variables this line uses that actually has the bug.
Answered By - Corley Brigman
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.