3

I am trying to learn Python, and I am still a novice so please bear with me. I am using the Komodo IDE environment. I currently wish to debug a a runtime warning that says:

RuntimeWarning: invalid value encountered in greater & (matrixCsvOutput[:,8] > 30))[0] ,:]

Now, I wish to set a breakpoint that would allow me to examine the composition of "matrixCsvOutput" at runtime. I expect that the value in question may be a null or a nan, and therefore fail the operation.

My question is: how can I set the debugger to break when the runtime error occurs? Many thanks in advance!

aag
  • 680
  • 2
  • 12
  • 33
  • I'm wondering about this 'matrixCsvOutput[:,8]' you have there. Usually slice notation would just look like 'matrixCsvOutput[:8]', with no comma. What's up with that? – Chara Jun 28 '14 at 18:57
  • Personally - if you are learning, I would strongly suggest that you don't use an IDE, learn how the program works by using individual files, and the interactive prompts. In my experience, the IDE can be responsible for hiding or munging issues, and thus prevent the novice from spotting novice mistakes. – Tony Suffolk 66 Jun 28 '14 at 20:31
  • 1
    @user2845306: matrixCsvOutput is a 2D numpy array. The slice encompasses the entire first axis and the 9th element of the second axis. Is there a better way to do that? Thanks in advance! – aag Jun 29 '14 at 20:25

3 Answers3

1

You can run your script through pdb from the command line too:

python -m pdb myscript.py

(command taken from the pdb docs)

daniel
  • 2,568
  • 24
  • 32
0

before the line number mentioned in RuntimeWarning, add this:

import pdb ; pdb.set_trace()
johntellsall
  • 14,394
  • 4
  • 46
  • 40
  • I don't think the answer is good enough to the point. The answer provides a solution for debugging in general -- even if there is no runtime warning, the interpreter will always stop at the line number where pdb is set. However, people may want to see it only stopping when runtime warnings happen. – Ray Oct 21 '22 at 00:49
0

To anyone (but probably not novice) who concerns only debugging the runtime warnings, you may find this post helpful.

Ray
  • 170
  • 3
  • 10