Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make PyCharm to break on Runtime warning?

Tags:

pycharm

I have encountered "RuntimeWarning: overflow encountered in exp ..." in my code. How do I make pyCharm break on this warning? It currently runs past it.

like image 512
Gary Avatar asked Jul 29 '13 22:07

Gary


People also ask

How do I enable Debug mode in PyCharm?

Just right-click any line in the editor and select the Debug <filename> command from the context menu. After the program has been suspended, use the debugger to get the information about the state of the program and how it changes during running.

How do you create a breakpoint in Python?

You can insert a breakpoint with the breakpoint() function at any position in your code . This is new in Python 3.7, and is equivalent to the older import pdb; pdb. set_trace() command. # my_script.py a = int(0.1) b = 3.0 c = a + b breakpoint() # a lot of more code here...

What does the lightning bolt mean in PyCharm?

Another breakpoint appeared as well: by default PyCharm will halt for any exception that wasn't caught in your code, and it'll show an icon of a breakpoint with a lightning bolt. The debugger also shows the error message.


1 Answers

I did my own research and similarly to what @doctorlove said, do

numpy.seterr(all='raise')

then numpy will raise exceptions instead of RuntimeWarnings. The exceptions can then be caught by PyCharm.

like image 113
Gary Avatar answered Sep 28 '22 08:09

Gary