为什么 binned_statistic_2d 现在抛出 TypeError?

Why is binned_statistic_2d now throwing TypeError?

我一直在使用 scipy 的 binned_statistic_2d 函数绘制一些数据的二维直方图,特别是 return 数据所在 bin 的索引列表,通过设置 expand_binnumbers = True。它运行完美,直到今天。以下代码演示了我的问题:

import numpy as np
from scipy.stats import binned_statistic_2d as hist 

# my data is two arrays of numbers 
x = np.random.random((5,))
y = np.random.random((5,))

# I need to know which bin the values are in so I return the bin_idx
data = hist(x,y, bins = [2,2], statistic = 'count', values = None, expand_binnumbers = True)

bin_idx = data[3]

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

知道为什么这会突然停止工作吗?

最近对 Scipy 的更新在某种程度上破坏了一些东西 - 正如@WarrenWeckesser 在评论中所说,设置 values = x 使事情再次发生。