我将 var1、var2 定义为以下数组:
N = 2e5
var1 = np.array(50 * np.random.normal(size=N) + 0.1)
var2 = np.array(0.01 * np.random.normal(size=N) - 300)
在 python 中运行这 3 个语句时,我收到以下两个警告:
__main__:7:
VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
__main__:8:
VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
如何纠正这个问题?
最佳答案
大小
必须是整数。您使用了 N=2e5
但那是一个 float ,您可以只使用 2 * 10**5
:
>>> type(2e5)
float
>>> type(2*10**5)
int
或者以其他方式将值转换为整数。
关于python - 创建大小为 2e5 的随机数组时 VisibleDeprecationWarning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43985277/