为什么 numpy.histogram 尝试使用索引 -9223372036854775808(int64 的最小数量)获取值?
Why numpy.histogram try to get value with index -9223372036854775808 (min number of int64)?
我的任务是计算不同数字数组的直方图(我事先不知道)。我对相同双数的数组有麻烦,例如:
double_numbers = np.array([1e20] * 20)
np.histogram(double_numbers, bins=100)
我收到一个错误:
IndexError Traceback (most recent call last)
<ipython-input-37-51958daa5f2c> in <module>()
1 double_numbers = np.array([1e20] * 20)
----> 2 np.histogram(double_numbers, bins=100)
/home/oleksandr/.pyenv/versions/2.7.8/envs/dr2.7.8/lib/python2.7/site-packages/numpy/lib/function_base.pyc in histogram(***failed resolving arguments***)
795 # The index computation is not guaranteed to give exactly
796 # consistent results within ~1 ULP of the bin edges.
--> 797 decrement = tmp_a_data < bin_edges[indices]
798 indices[decrement] -= 1
799 # The last bin includes the right edge. The other bins do not.
IndexError: index -9223372036854775808 is out of bounds for axis 1 with size 101
为什么 numpy.histogram 尝试使用索引 -9223372036854775808(int64 的最小值)获取值? numpy有没有bug?
这是一个已知错误 https://github.com/numpy/numpy/issues/8627,已经存在大约 2 年了
我的任务是计算不同数字数组的直方图(我事先不知道)。我对相同双数的数组有麻烦,例如:
double_numbers = np.array([1e20] * 20)
np.histogram(double_numbers, bins=100)
我收到一个错误:
IndexError Traceback (most recent call last)
<ipython-input-37-51958daa5f2c> in <module>()
1 double_numbers = np.array([1e20] * 20)
----> 2 np.histogram(double_numbers, bins=100)
/home/oleksandr/.pyenv/versions/2.7.8/envs/dr2.7.8/lib/python2.7/site-packages/numpy/lib/function_base.pyc in histogram(***failed resolving arguments***)
795 # The index computation is not guaranteed to give exactly
796 # consistent results within ~1 ULP of the bin edges.
--> 797 decrement = tmp_a_data < bin_edges[indices]
798 indices[decrement] -= 1
799 # The last bin includes the right edge. The other bins do not.
IndexError: index -9223372036854775808 is out of bounds for axis 1 with size 101
为什么 numpy.histogram 尝试使用索引 -9223372036854775808(int64 的最小值)获取值? numpy有没有bug?
这是一个已知错误 https://github.com/numpy/numpy/issues/8627,已经存在大约 2 年了