在 1.17 的 numpy 中
In [216]: np.linspace(0,1,10.)
Out[216]:
array([0. , 0.11111111, 0.22222222, 0.33333333, 0.44444444,
0.55555556, 0.66666667, 0.77777778, 0.88888889, 1. ])
更新到 1.18
In [2]: np.linspace(0,10,10.)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/numpy/core/function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis)
116 try:
--> 117 num = operator.index(num)
118 except TypeError:
TypeError: 'float' object cannot be interpreted as an integer
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-2-1e9a5a5e4a05> in <module>
----> 1 np.linspace(0,10,10.)
<__array_function__ internals> in linspace(*args, **kwargs)
/usr/local/lib/python3.6/dist-packages/numpy/core/function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis)
119 raise TypeError(
120 "object of type {} cannot be safely interpreted as an integer."
--> 121 .format(type(num)))
122
123 if num < 0:
TypeError: object of type <class 'float'> cannot be safely interpreted as an integer.
该num = operator.index(num)
测试曾经在deprecation
警告功能中num = _index_deprecate(num)
,现在它引发了错误。
https://github.com/numpy/numpy/blob/v1.17.0/numpy/core/function_base.py#L37-L179