'Vector assignment to Dask array

I'm trying to change the slice in Dask array row-wise and col-wise way:

from dask import array as da
A = da.from_array(np.zeros((3,3)))
A[[0,1,2], 0] = [1,2,3]
A.compute()

And I've got:

array([[1., 0., 0.],
       [2., 0., 0.],
       [3., 0., 0.]])

But in row-wise way:

A = da.from_array(np.zeros((3,3)))
A[0,[0,1,2]] = [1,2,3]
A.compute()

TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'

Do You where the problem is? Or any other method to do this kind of assignment?



Solution 1:[1]

Since this may be a bug, here are some workarounds to do the same operation:

  • A[0:1, [0,1,2]] = [1,2,3]
  • A[0] = [1,2,3]

Ref: https://docs.dask.org/en/stable/array-assignment.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pavithraes