Open kanglcn opened 1 year ago
This works:
arr = da.ones((100,100),chunks=(10,10),dtype=bool) arr_delayed = arr.to_delayed() num_true_delayed = np.empty_like(arr_delayed,dtype=object) with np.nditer(arr_delayed,flags=['multi_index','refs_ok'], op_flags=['readwrite']) as arr_it: for arr_block in arr_it: idx = arr_it.multi_index num_true_delayed[idx] = delayed(np.count_nonzero)(arr_delayed[idx],keepdims=True) num_true_delayed[idx] = da.from_delayed(num_true_delayed[idx],shape=(1,1),meta=np.array((),dtype=int)) num_true = da.block(num_true_delayed.tolist()) num_true.compute()
but this doesn't work:
arr = da.ones((100,100),chunks=(10,10),dtype=bool) arr_delayed = arr.to_delayed() num_true_delayed = np.empty_like(arr_delayed,dtype=object) with np.nditer(arr_delayed,flags=['multi_index','refs_ok'], op_flags=['readwrite']) as arr_it: for arr_block in arr_it: idx = arr_it.multi_index num_true_delayed[idx] = delayed(np.count_nonzero)(arr_block,keepdims=True) num_true_delayed[idx] = da.from_delayed(num_true_delayed[idx],shape=(1,1),meta=np.array((),dtype=int)) num_true = da.block(num_true_delayed.tolist()) num_true.compute()
I have no idea with this.
This works:
but this doesn't work:
I have no idea with this.