我首先要避免被零除:
if a == 0: # Break out early# Otherwise the ratio makes sense
如果您确实希望将特定的numpy警告压缩为一行,则numpy提供了一种方法:
with numpy.errstate(divide='ignore'): # The problematic line

我首先要避免被零除:
if a == 0: # Break out early# Otherwise the ratio makes sense
如果您确实希望将特定的numpy警告压缩为一行,则numpy提供了一种方法:
with numpy.errstate(divide='ignore'): # The problematic line