[英]convert numpy warnings to errors
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 (eg 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.
但问题仍然存在。
import warnings
warnings.filterwarnings('error', "Mean of empty slice.")
# ... Your code here.
See the documentation of the warnings
module for more details. 有关更多详细信息,请参阅
warnings
模块的文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.