-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expected behavior of dask.array.full() for non-scalar fill values? #6107
Copy link
Copy link
Closed
Labels
arraygood first issueClearly described and easy to accomplish. Good for beginners to the project.Clearly described and easy to accomplish. Good for beginners to the project.
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
arraygood first issueClearly described and easy to accomplish. Good for beginners to the project.Clearly described and easy to accomplish. Good for beginners to the project.