id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 859933298,MDU6SXNzdWU4NTk5MzMyOTg=,5171,Dask now supports item assignment. Shouldn't xarray support it too?,9049976,closed,0,,,2,2021-04-16T15:38:40Z,2021-05-01T23:35:44Z,2021-05-01T23:35:44Z,CONTRIBUTOR,,,,"As of a few weeks ago, dask now supports [item assignment](https://github.com/dask/dask/commit/a199302b0c69df82a09c8ab166de882368e6e8c8). [Documentation here](https://docs.dask.org/en/latest/array-assignment.html). At the moment, xarray prevents item assignment if a DataArray uses dask arrays. ``` >>> import xarray as xr >>> foo = xr.DataArray([1,2,3,4,5,6], dims=('x'), coords={'x':[1,2,3,4,5,6]}).chunk(2) >>> foo.loc[1] = 44 Traceback (most recent call last): File """", line 1, in File ""/home/tammas/miniconda3/envs/da/lib/python3.8/site-packages/xarray/core/dataarray.py"", line 213, in __setitem__ self.data_array[pos_indexers] = value File ""/home/tammas/miniconda3/envs/da/lib/python3.8/site-packages/xarray/core/dataarray.py"", line 724, in __setitem__ self.variable[key] = value File ""/home/tammas/miniconda3/envs/da/lib/python3.8/site-packages/xarray/core/variable.py"", line 889, in __setitem__ indexable[index_tuple] = value File ""/home/tammas/miniconda3/envs/da/lib/python3.8/site-packages/xarray/core/indexing.py"", line 1379, in __setitem__ raise TypeError( TypeError: this variable's data is stored in a dask array, which does not support item assignment. To assign to this variable, you must first load it into memory explicitly using the .load() method or accessing its .values attribute. ``` Now that this is possible in dask, shouldn't xarray allow it too if the installed dask version supports it? Kind regards, Tam ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5171/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 860073545,MDExOlB1bGxSZXF1ZXN0NjE3MDQwNjIy,5174,Enable __setitem__ for dask versions that support it.,9049976,closed,0,,,13,2021-04-16T18:33:28Z,2021-05-01T19:59:37Z,2021-05-01T19:59:37Z,CONTRIBUTOR,,0,pydata/xarray/pulls/5174,"The basics seem to work for me with just these changes. But I haven't tested much to see if it plays nicely with the rest of xarray. Looks like dask's item assignment is still mostly limited to 1D arrays and slices of multi dimensional arrays—no fancy stuff. ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5174/reactions"", ""total_count"": 4, ""+1"": 4, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull