当我导入许多库(例如numpy,matplotlib等)时,我被除以零警告,其方式与在代码中弄错eqn时所发生的方式几乎相同。虽然这并不能阻止我使用该软件包,但它令人沮丧,并且由于我是python和学习的新手,所以我不知道如何抑制它们。
例如,仅运行“ import numpy”会导致12条警告,这些警告均与以下内容类似
C:\mydirectory\numpy\__init__.py:244: RuntimeWarning: divide by zero encountered in subtract
if not abs(x.dot(x) - 2.0) < 1e-5:
C:\mydirectory\numpy\__init__.py:244: RuntimeWarning: divide by zero encountered in absolute
if not abs(x.dot(x) - 2.0) < 1e-5:
有什么简单的方法可以解决?
答案 0 :(得分:0)
您可以使用warnings软件包禁止所有来自不同软件包的警告。只需在代码开头添加以下行即可。
W/FlutterActivity: Tried to automatically register plugins with FlutterEngine (io.flutter.embedding.engine.FlutterEngine@7fa53ce) but could not find and invoke the GeneratedPluginRegistrant.
W/rf_mesh_exampl: Accessing hidden method Landroid/view/accessibility/AccessibilityNodeInfo;->getSourceNodeId()J (greylist, reflection, allowed)
W/rf_mesh_exampl: Accessing hidden method Landroid/view/accessibility/AccessibilityRecord;->getSourceNodeId()J (greylist, reflection, allowed)
W/rf_mesh_exampl: Accessing hidden field Landroid/view/accessibility/AccessibilityNodeInfo;->mChildNodeIds:Landroid/util/LongArray; (greylist, reflection, allowed)
W/rf_mesh_exampl: Accessing hidden method Landroid/util/LongArray;->get(I)J (greylist, reflection, allowed)
I/mali_winsys: new_window_surface() [1080x2214] return: 0x3000
I/mali_winsys: new_window_surface() [1080x2340] return: 0x3000
W/Gralloc3: mapper 3.x is not supported
I/gralloc: Arm Module v1.0