dask 不支持项目分配的解决方法

Workaround for Item assignment not supported in dask

我正在尝试将我的代码库从 numpy 数组转换为 dask,因为我的 numpy 数组超出了 Memory Error 限制。但是,我知道 dask arrays 中尚未实现可变数组的功能,所以我得到
NotImplementedError: Item assignment with <class 'tuple'> not supported
我的代码是否有任何解决方法-

for i, mask in enumerate(masks):
    bounds = find_boundaries(mask, mode='inner')
    X2, Y2 = np.nonzero(bounds)
    X2 = da.from_array(X2, 'auto')
    Y2 = da.from_array(Y2, 'auto')
    xSum = (X2.reshape(-1, 1) - X1.reshape(1, -1)) ** 2
    ySum = (Y2.reshape(-1, 1) - Y1.reshape(1, -1)) ** 2
    #Failing on below line
    distMap[:,i] = da.sqrt(xSum + ySum).min(axis=0)

    break

我还尝试在 dask 中计算所有其他计算并使用 distMap 作为 numpy 数组,但仍然得到 Memory Error。 欢迎任何解决方法。

也许你可以构建多个 dask 数组,然后使用 da.concatenateda.stack 将它们合并为一个 dask 数组?