Python形状给出了不正确的结果

Python形状给出了不正确的结果,python,Python,我使用pylibtiff读取带有get_samples函数的图像。 错误是: arr[i:i + xxx] = d ValueError: could not broadcast input array from shape (1360) into shape (1347) 我修改了错误点附近的代码以查找错误: if compression == 1: # none d = self.data[start:end] elif compression == 5: # lzw

我使用pylibtiff读取带有get_samples函数的图像。 错误是:

arr[i:i + xxx] = d ValueError: could not broadcast input array from shape (1360) into shape (1347)
我修改了错误点附近的代码以查找错误:

if compression == 1:  # none
    d = self.data[start:end]
elif compression == 5:  # lzw
    d = self.data[start:end]
    d = tif_lzw.decode(d, bytes_per_strip)
print(compression, d, d.shape, d.nbytes, i, i + d.nbytes)
print(d.nbytes, arr[i:i + d.nbytes].shape)
arr[i:i + d.nbytes] = d
i += d.nbytes
但我还是得到了结果:

5 [0 0 0 ..., 0 0 0] (1360,) 1360 82305853 82307213 

1360 (1347,)

这怎么可能呢?d、 nbytes为1360,is为82305853,i+d。nbytes=82307213。1347从何而来?

它可能有助于人们发布一个完整的片段,并链接到tiff源代码,以重现该问题……尝试打印出
arr
-我想你会发现它的长度是82305853+1347字节,因此,您的切片
i:i+d.nbytes
略微超出数组的末尾,并被静默地截断。是的,就是这样。该错误是由于阵列的大小较短造成的。