完整错误信息如下:
IndexError: only integers, slices (
:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices
经检查,错误之处在索引处使用了浮点数,修改后部分代码如下:
h=int(h) #修改成整型
w=int(w) #修改成整型
return Cluster(h, w,
self.data[h][w][0],
self.data[h][w][1],
self.data[h][w][2])
题记。