源码:
#阶跃函数
import numpy as np
import matplotlib.pylab as plt
def step_function(x):
return np.array(x > 0, dtype = np.int) #重点关注
x = np.arange(-5.0, 5.0, 0.1)
y = step_function(x)
plt.plot(x, y)
plt.ylim(-0.1, 1.1)
plt.show()
?
警告:
<ipython-input-1-7e47265f9293>:6: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: NumPy 1.20.0 Release Notes — NumPy v1.22.dev0 Manual
return np.array(x > 0, dtype = np.int)
分析:
简单的说,就是当前的Numpy版本希望你将np.int格式改为np.int64或np.int32的格式。如果不换的话也不影响,但是每次运行代码时,警告也会随之出现。
?
|