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
1887536475,PR_kwDOAMm_X85Z3rFM,8159,Update Variable metadata when using 'a' mode in Zarr,38408316,open,0,,,2,2023-09-08T11:55:31Z,2023-10-14T20:14:57Z,,CONTRIBUTOR,,1,pydata/xarray/pulls/8159,"
- [x] Closes #8116, #3536
- [x] Tests added
- [ ] User visible changes (including notable bug fixes) are documented in `whats-new.rst`
- [ ] New functions/methods are listed in `api.rst`
Because the DataArray in a DataSet's data variable when saving to zarr, the incorrect metadata update behaviour applies to it. This is an attempt to fix the TODO left by [PR5252](https://github.com/pydata/xarray/pull/5252). The tests are passing, but as I'm quite new to this repo, I'm not sure what cases should be tested as well. @shoyer could you share some insight please?","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8159/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull
1867170572,I_kwDOAMm_X85vSsMM,8116,Updating DataArray attributes in a Zarr archive does not work as for Dataset,38408316,open,0,,,1,2023-08-25T14:34:46Z,2023-09-21T20:32:38Z,,CONTRIBUTOR,,,,"### What happened?
When using the new functionality of calling `to_zarr` on DataArrays, I've noticed that the attributes are not updated and can only be set once, on initial archive creation. In our case, we are performing sequential writes to the Zarr regions and also want to update attributes. Regular Zarr API allows updating metadata and it also works with Datasets, so we suspect it's an issue with DataArrays. In fact, when calling `to_zarr`, the DataArray is converted to a Dataset, but when we check it, it does not have its attributes, as they live inside the nested array.
### What did you expect to happen?
I would like to update attributes in the same manner as with plain Zarr or with Datasets. Currently, we have to resort to modifying the `.zmetadata` JSON and consider this dangerous and hacky.
### Minimal Complete Verifiable Example
```Python
import xarray as xr
ds_path = ""ds""
xr.Dataset().assign_attrs(a=1).to_zarr(ds_path, mode=""w"")
xr.open_dataset(ds_path, engine=""zarr"").assign_attrs(b=2).to_zarr(ds_path, mode=""a"")
da_path = ""da""
xr.DataArray().assign_attrs(a=1).to_zarr(da_path, mode=""w"")
xr.open_dataarray(da_path, engine=""zarr"").assign_attrs(b=2).to_zarr(da_path, mode=""a"")
print(xr.open_dataset(ds_path, engine=""zarr"").attrs == xr.open_dataarray(da_path, engine=""zarr"").attrs)
```
### MVCE confirmation
- [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- [X] Complete example — the example is self-contained, including all data and the text of any traceback.
- [X] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result.
- [X] New issue — a search of GitHub Issues suggests this is not a duplicate.
### Relevant log output
_No response_
### Anything else we need to know?
_No response_
### Environment
INSTALLED VERSIONS
------------------
commit: None
python: 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 183 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: ('Polish_Poland', '1250')
libhdf5: None
libnetcdf: None
xarray: 2023.7.0
pandas: 2.0.3
numpy: 1.25.2
scipy: 1.11.2
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: 2.16.1
cftime: None
nc_time_axis: None
PseudoNetCDF: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: 3.7.2
cartopy: None
seaborn: None
numbagg: None
fsspec: None
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 68.0.0
pip: 23.2.1
conda: None
pytest: None
mypy: None
IPython: 8.14.0
sphinx: 7.1.2
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8116/reactions"", ""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
1891307093,PR_kwDOAMm_X85aEMt5,8174,Exclude dimensions used in faceting from squeeze,38408316,closed,0,,,1,2023-09-11T21:39:54Z,2023-09-17T05:08:07Z,2023-09-17T05:08:05Z,CONTRIBUTOR,,0,pydata/xarray/pulls/8174,"
- [x] Closes #7552
- [x] Tests added
- [x] User visible changes (including notable bug fixes) are documented in `whats-new.rst`
Implements @headtr1ck solution from the issue.
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8174/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull
1861335844,I_kwDOAMm_X85u8bsk,8096,Errors when saving PyObject coordinates,38408316,closed,0,,,4,2023-08-22T12:14:53Z,2023-09-06T11:44:41Z,2023-09-06T11:44:41Z,CONTRIBUTOR,,,,"### What happened?
Hi, I'm trying to create a `DataArray` with coordinates that are tuples and potentionally even more dimensional objects. The way I did it is to create an empty `numpy` array with `dtype=object` and then insert my tuples inside. This doesn't throw an error when creating a `DataArray` (as opposed to using a 2D ndarray or a list of lists). However, when trying to save it to `zarr` or `netcdf`. I get an error saying `ValueError: setting an array element with a sequence`
### What did you expect to happen?
I want to be able to save and load such coordinates without errors. Maybe there is a cleaner way to do it than the object dtype ndarray?
### Minimal Complete Verifiable Example
```Python
n = 5
x = np.empty(n, dtype=object)
for i in range(n):
x[i] = (i, i)
xr.DataArray(np.arange(n), dims=(""x""), coords={""x"": x}).to_zarr(""test"")
```
### MVCE confirmation
- [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- [X] Complete example — the example is self-contained, including all data and the text of any traceback.
- [X] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result.
- [X] New issue — a search of GitHub Issues suggests this is not a duplicate.
### Relevant log output
```Python
File c:\Users\Wiktor\AppData\Local\pypoetry\Cache\virtualenvs\spin1-JGuolXDk-py3.11\Lib\site-packages\xarray\core\dataarray.py:4014, in DataArray.to_netcdf(self, path, mode, format, group, engine, encoding, unlimited_dims, compute, invalid_netcdf)
4010 else:
4011 # No problems with the name - so we're fine!
4012 dataset = self.to_dataset()
-> 4014 return to_netcdf( # type: ignore # mypy cannot resolve the overloads:(
4015 dataset,
4016 path,
4017 mode=mode,
4018 format=format,
4019 group=group,
4020 engine=engine,
4021 encoding=encoding,
4022 unlimited_dims=unlimited_dims,
...
101 result = np.empty(data.shape, dtype)
--> 102 result[...] = data
103 return result
ValueError: setting an array element with a sequence.
```
### Anything else we need to know?
_No response_
### Environment
INSTALLED VERSIONS
------------------
commit: None
python: 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 183 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: ('Polish_Poland', '1250')
libhdf5: None
libnetcdf: None
xarray: 2023.8.0
pandas: 2.0.3
numpy: 1.25.2
scipy: 1.11.2
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: 2.16.0
cftime: None
nc_time_axis: None
PseudoNetCDF: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: 3.7.2
cartopy: None
seaborn: None
numbagg: None
fsspec: None
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 68.0.0
pip: 23.2.1
conda: None
pytest: None
mypy: None
IPython: 8.14.0
sphinx: 7.1.2
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8096/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue