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 1060646604,I_kwDOAMm_X84_OC7M,6015,TypeError: '_ElementwiseFunctionArray' object does not support item assignment,25624127,open,0,,,0,2021-11-22T22:19:24Z,2021-11-22T23:38:17Z,,CONTRIBUTOR,,,," **What happened**: I am attempting to mask specific `time_bnds` coordinate points using `loc`, but am receiving `TypeError: '_ElementwiseFunctionArray' object does not support item assignment`. This happens when calling `ds = xr.open_dataset(""path/to/file"", decode_times=False)`, followed by `ds = xr.decode_cf(ds, decode_times=True`). **What you expected to happen**: The `time_bnds` coordinate points selected using `.loc` should mask. **Minimal Complete Verifiable Example**: ```python import numpy as np import xarray as xr file_path = ""./input/ts_Amon_ACCESS1-0_historical_r1i1p1_185001-200512.nc"" # This works fine ds = xr.open_dataset(file_path, decode_times=True) ds[""time_bnds""].loc[dict(time=""1850-01"")] = np.nan # This breaks ds2 = xr.open_dataset(file_path, decode_times=False) ds2 = xr.decode_cf(ds2, decode_times=True) ds2[""time_bnds""].loc[dict(time=""1850-01"")] = np.nan --------------------------------------------------------------------------- TypeError Traceback (most recent call last) ~/Documents/Repositories/XCDAT/xcdat/qa/PR47 temporal avg/bugs/qa_seasonal_bug.py in 13 ds2 = xr.open_dataset(file_path, decode_times=False) 14 ds2 = xr.decode_cf(ds2, decode_times=True) ----> 15 ds2[""time_bnds""].loc[dict(time=""1850-01"")] = np.nan /opt/miniconda3/envs/xcdat_dev/lib/python3.9/site-packages/xarray/core/dataarray.py in __setitem__(self, key, value) 212 213 pos_indexers, _ = remap_label_indexers(self.data_array, key) --> 214 self.data_array[pos_indexers] = value 215 216 /opt/miniconda3/envs/xcdat_dev/lib/python3.9/site-packages/xarray/core/dataarray.py in __setitem__(self, key, value) 765 for k, v in self._item_key_to_dict(key).items() 766 } --> 767 self.variable[key] = value 768 769 def __delitem__(self, key: Any) -> None: /opt/miniconda3/envs/xcdat_dev/lib/python3.9/site-packages/xarray/core/variable.py in __setitem__(self, key, value) 852 853 indexable = as_indexable(self._data) --> 854 indexable[index_tuple] = value 855 856 @property /opt/miniconda3/envs/xcdat_dev/lib/python3.9/site-packages/xarray/core/indexing.py in __setitem__(self, key, value) 435 ) 436 full_key = self._updated_key(key) --> 437 self.array[full_key] = value 438 439 def __repr__(self): TypeError: '_ElementwiseFunctionArray' object does not support item assignment ``` **Anything else we need to know?**: The workaround is to perform `.load()` after `xr.decode_cf()` ```python # This works ds3 = xr.open_dataset(file_path, decode_times=False) ds3 = xr.decode_cf(ds3, decode_times=True) ds3.load() ds3[""time_bnds""].loc[dict(time=""1850-01"")] = np.nan ``` **Environment**:
Output of xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 20:33:18) [Clang 11.1.0 ] python-bits: 64 OS: Darwin OS-release: 19.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: None LOCALE: (None, 'UTF-8') libhdf5: 1.12.1 libnetcdf: 4.8.1 xarray: 0.19.0 pandas: 1.3.3 numpy: 1.21.2 scipy: None netCDF4: 1.5.7 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.5.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.2 dask: 2021.09.1 distributed: 2021.09.1 matplotlib: None cartopy: None seaborn: None numbagg: None pint: None setuptools: 58.2.0 pip: 21.2.4 conda: None pytest: 6.2.5 IPython: 7.28.0 sphinx: 4.2.0
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6015/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue