为什么np.full会提出FutureWarning?

时间:2015-10-11 21:47:07

标签: python numpy warnings

我在python 2.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可能会有所帮助,但我不明白为什么在这个简单的情况下它也会弹出。这是一个错误吗?

1 个答案:

答案 0 :(得分:1)

当提供的值已经是p3 = &s1[3]; 时,警告的作者选择了避免错误警告的测试。不幸的是,他们忽略了你明确提供的dtype也意味着警告是假的情况。

https://github.com/numpy/numpy/pull/6382