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.
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.
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...
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With