【发布时间】:2013-04-26 12:36:47
【问题描述】:
执行我写的 python 脚本(在这里包含很长)会导致一条警告消息。我不知道这是在我的代码中的哪一行提出的。我怎样才能得到这些信息?
此外,这究竟是什么意思?事实上,我不知道我在使用某种掩码数组?
/usr/lib/pymodules/python2.7/numpy/ma/core.py:3785: UserWarning: Warning: converting a masked element to nan.
warnings.warn("Warning: converting a masked element to nan.")
【问题讨论】:
-
我会在您的代码中围绕所有可能的罪魁祸首添加很多
print语句,这将为您提供正在发生的事情的时间表,在您的prints 之间的某个位置,您将看到此警告, 这样您就可以本地化您的问题。如果有帮助,警告来自MaskedArray.__float__,它显然将数组转换为浮点数。另一种方法是(临时)编辑core.py以使其输出有用的信息,例如数组的属性。调试器也是可行的选择。 -
打印语句帮我找到了对应的行,谢谢!我只是认为可能有更复杂的解决方案。