为什么numpy.histogram尝试使用索引-9223372036854775808(最小的int64数)获取值?

时间:2018-11-01 10:55:59

标签: python numpy histogram index-error

我的任务是对不同数字数组的计数直方图(我事先不知道)。而且我对相同的双数数组有麻烦,例如:

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的错误吗?

1 个答案:

答案 0 :(得分:0)

这是一个已知的错误https://github.com/numpy/numpy/issues/8627,已经存在大约2年