为什么 np.full 引发 FutureWarning?
Why does np.full raise a FutureWarning?
我运行下面的代码在python2.7
Python 2.7.10 (default, Aug 25 2015, 12:33:52)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.__version__
'1.10.0'
>>> np.full(1, 1, np.double)
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/numeric.py:294: FutureWarning: in the future, full(..., 1) will return an array of dtype('int64')
format(fill_value, array(fill_value).dtype), FutureWarning)
array([ 1.])
如果我不提供 dtype
,FutureWarning 可能会有帮助,但我不明白为什么它也会在这种简单的情况下弹出。这是一个错误吗?
警告的作者选择了一个测试,该测试在提供的值已经是 float64
时避免了错误警告。不幸的是,他们忽略了您的情况,您明确提供的 dtype 也意味着警告是错误的。
我运行下面的代码在python2.7
Python 2.7.10 (default, Aug 25 2015, 12:33:52)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.__version__
'1.10.0'
>>> np.full(1, 1, np.double)
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/numeric.py:294: FutureWarning: in the future, full(..., 1) will return an array of dtype('int64')
format(fill_value, array(fill_value).dtype), FutureWarning)
array([ 1.])
如果我不提供 dtype
,FutureWarning 可能会有帮助,但我不明白为什么它也会在这种简单的情况下弹出。这是一个错误吗?
警告的作者选择了一个测试,该测试在提供的值已经是 float64
时避免了错误警告。不幸的是,他们忽略了您的情况,您明确提供的 dtype 也意味着警告是错误的。