-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
arrayneeds attentionIt's been a while since this was pushed on. Needs attention from the owner or a maintainer.It's been a while since this was pushed on. Needs attention from the owner or a maintainer.
Description
What happened:
I get a ValueError when I use a 1D dask index array to make an assignment on another dask array.
Minimal Complete Verifiable Example:
This
import dask.array as da
x = da.zeros(10)
x[da.arange(3)] = 1raises the following error:
ValueError Traceback (most recent call last)
~/Documents/FOSS/dask-tlouf/dask/array/core.py in __setitem__(self, key, value)
1720 try:
-> 1721 y = where(key, value, self)
1722 except ValueError as e:
~/Documents/FOSS/dask-tlouf/dask/array/routines.py in where(condition, x, y)
2037 else:
-> 2038 return elemwise(np.where, condition, x, y)
2039
~/Documents/FOSS/dask-tlouf/dask/array/core.py in elemwise(op, out, where, dtype, name, *args, **kwargs)
4441 out_ndim = len(
-> 4442 broadcast_shapes(*shapes)
4443 ) # Raises ValueError if dimensions mismatch
~/Documents/FOSS/dask-tlouf/dask/array/core.py in broadcast_shapes(*shapes)
4369 if any(i not in [-1, 0, 1, dim] and not np.isnan(i) for i in sizes):
-> 4370 raise ValueError(
4371 "operands could not be broadcast together with "
ValueError: operands could not be broadcast together with shapes (3,) () (10,)
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
<ipython-input-9-7ccc3d8dfd86> in <module>
1 x = da.zeros(10)
----> 2 x[da.arange(3)] = 1
~/Documents/FOSS/dask-tlouf/dask/array/core.py in __setitem__(self, key, value)
1721 y = where(key, value, self)
1722 except ValueError as e:
-> 1723 raise ValueError(
1724 "Boolean index assignment in Dask "
1725 "expects equally shaped arrays.\nExample: da1[da2] = da3 "
ValueError: Boolean index assignment in Dask expects equally shaped arrays.
Example: da1[da2] = da3 where da1.shape == (4,), da2.shape == (4,) and da3.shape == (4,).while curiously this does not:
x = da.zeros(10)
x[da.arange(3),] = 1Environment:
- Dask version: 2021.11.2+18.g43247806 (just pulled)
- Python version: 3.9.5
- Operating System: Pop!_OS 21.04 x86_64
- Install method (conda, pip, source): source
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
arrayneeds attentionIt's been a while since this was pushed on. Needs attention from the owner or a maintainer.It's been a while since this was pushed on. Needs attention from the owner or a maintainer.