What is the expected behavior for dask.array.full() for a non-scalar fill_value?
The numpy.full() signature in the documentation mentions "scalar" for fill_value.
https://docs.scipy.org/doc/numpy/reference/generated/numpy.full.html
However, it'll broadcast non-scalar values if it can:
a = np.full((3, 2), [1, 2])
Since dask.array.full() wraps this function, it works similarly:
import dask.array
a1 = dask.array.full((2, 3), [[1, 2, 3], [4, 5, 6]])
a1.compute()
The issue is that when the chunk sizes change, it won't work anymore, as it starts broadcasting per chunk:
a2 = dask.array.full((2, 3), [[1, 2, 3], [4, 5, 6]], chunks=(1, 3))
a2.compute() # ValueError: could not broadcast input array from shape (2,3) into shape (1,3)
a3 = dask.array.full((2, 3), [1, 2, 3], chunks=(1, 3))
a3.compute()
My feeling is that choosing different chunk sizes shouldn't lead to different behavior here. I think I'd prefer a ValueError for a non-scalar fill_value.
What is the expected behavior for
dask.array.full()for a non-scalarfill_value?The
numpy.full()signature in the documentation mentions "scalar" forfill_value.https://docs.scipy.org/doc/numpy/reference/generated/numpy.full.html
However, it'll broadcast non-scalar values if it can:
Since
dask.array.full()wraps this function, it works similarly:The issue is that when the chunk sizes change, it won't work anymore, as it starts broadcasting per chunk:
My feeling is that choosing different chunk sizes shouldn't lead to different behavior here. I think I'd prefer a ValueError for a non-scalar fill_value.