I am getting
C:\Anaconda\lib\site-packages\numpy\core\_methods.py:59: RuntimeWarning: Mean of empty slice.
warnings.warn("Mean of empty slice.", RuntimeWarning)
when I run a code I wrote. This is a large codebase. The problem is, I do not see where in my code this warning was fired.
I would rather have this as an error (e.g. an exception), so that I can see where this was generated in my code.
Is it possible to have exceptions instead of warnings?
Note: I solved my problem debugging line by line. But the question still stands.
Setting
numpy.seterr(all='raise')
should do the trick. You should probably check out the details though.
import warnings
warnings.filterwarnings('error', "Mean of empty slice.")
# ... Your code here.
See the documentation of the warnings
module for more details.
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