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 1466586967,I_kwDOAMm_X85XaldX,7328,Zarr store array dtype changes for empty object string,85085,closed,0,,,2,2022-11-28T15:05:14Z,2023-06-16T03:56:16Z,2023-06-16T03:56:16Z,CONTRIBUTOR,,,,"### What happened? Saving a dataset with an empty object (string) variable to zarr changes the dtype to float64. ### What did you expect to happen? The dtype should remain as `O`, just as it does for non-empty object variables. ### Minimal Complete Verifiable Example ```Python import numpy as np import xarray as xr ds = xr.Dataset({""a"": np.array([], dtype=""O"")}) ds[""a""].dtype # prints: dtype('O') ds.to_zarr(""a.zarr"") ds = xr.open_dataset(""a.zarr"") ds[""a""].dtype # prints: dtype('float64') ``` ### 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.8.13 (default, Mar 28 2022, 06:16:26) [Clang 12.0.0 ] python-bits: 64 OS: Darwin OS-release: 21.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: ('en_GB', 'UTF-8') libhdf5: None libnetcdf: None xarray: 2022.11.0 pandas: 1.5.0 numpy: 1.23.4 scipy: 1.9.2 netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: 2.13.3 cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2022.10.0 distributed: 2022.10.0 matplotlib: 3.6.1 cartopy: None seaborn: 0.12.0 numbagg: None fsspec: 2022.8.2 cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 63.4.1 pip: 22.2.2 conda: None pytest: 7.1.3 IPython: 8.5.0 sphinx: 4.2.0
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7328/reactions"", ""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 1429920838,I_kwDOAMm_X85VOtxG,7243,Some aggregate operations using the array API fail,85085,open,0,,,0,2022-10-31T14:15:00Z,2023-01-15T16:02:00Z,,CONTRIBUTOR,,,,"### What happened? Here are some tests demonstrating the problem https://github.com/pydata/xarray/commit/9d6269de9fec4c66aeade2fdf9829c6e066a6eac: ``` FAILED xarray/tests/test_array_api.py::test_aggregation[max] - assert False FAILED xarray/tests/test_array_api.py::test_aggregation[min] - assert False FAILED xarray/tests/test_array_api.py::test_aggregation[mean] - assert False FAILED xarray/tests/test_array_api.py::test_aggregation[prod] - assert False FAILED xarray/tests/test_array_api.py::test_aggregation[std] - assert False FAILED xarray/tests/test_array_api.py::test_aggregation[var] - assert False FAILED xarray/tests/test_array_api.py::test_aggregation_skipna[std] - TypeError: std() got an unexpected keyword argument 'ddof' FAILED xarray/tests/test_array_api.py::test_aggregation_skipna[var] - TypeError: var() got an unexpected keyword argument 'ddof' ``` ### What did you expect to happen? _No response_ ### Minimal Complete Verifiable Example _No response_ ### MVCE confirmation - [ ] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray. - [ ] Complete example — the example is self-contained, including all data and the text of any traceback. - [ ] 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. - [ ] 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: 9d6269de9fec4c66aeade2fdf9829c6e066a6eac python: 3.8.13 (default, Mar 28 2022, 06:16:26) [Clang 12.0.0 ] python-bits: 64 OS: Darwin OS-release: 21.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: ('en_GB', 'UTF-8') libhdf5: None libnetcdf: None xarray: 2022.6.1.dev63+ge6791852a pandas: 1.5.0 numpy: 1.23.3 scipy: None netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: None cartopy: None seaborn: None numbagg: None fsspec: None cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 63.4.1 pip: 22.1.2 conda: None pytest: 7.1.3 IPython: None sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7243/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 1165277802,I_kwDOAMm_X85FdLpq,6347,Can't set write_empty_chunks in Zarr encoding,85085,closed,0,,,0,2022-03-10T14:11:36Z,2022-03-17T04:52:10Z,2022-03-17T04:52:10Z,CONTRIBUTOR,,,,"### What happened? Zarr 2.11.0 made [a change where chunks with data equal to the fill value are no longer written to disk by default](https://zarr.readthedocs.io/en/stable/release.html#release-2-11-0). I would like to override the default, but this isn't possible using xarray's `to_zarr`. ### What did you expect to happen? _No response_ ### Minimal Complete Verifiable Example ```Python import numpy as np import xarray as xr ds = xr.Dataset({""x"": ((""d1""), np.full((2,), np.nan))}) ds.to_zarr(""/tmp/ds.zarr"", encoding={""x"": {""write_empty_chunks"":True}}) ``` ### Relevant log output ```Python Traceback (most recent call last): File """", line 1, in File ""/Users/tom/miniconda/envs/sgkit-3.8/lib/python3.8/site-packages/xarray/core/dataset.py"", line 2036, in to_zarr return to_zarr( File ""/Users/tom/miniconda/envs/sgkit-3.8/lib/python3.8/site-packages/xarray/backends/api.py"", line 1431, in to_zarr dump_to_store(dataset, zstore, writer, encoding=encoding) File ""/Users/tom/miniconda/envs/sgkit-3.8/lib/python3.8/site-packages/xarray/backends/api.py"", line 1119, in dump_to_store store.store(variables, attrs, check_encoding, writer, unlimited_dims=unlimited_dims) File ""/Users/tom/miniconda/envs/sgkit-3.8/lib/python3.8/site-packages/xarray/backends/zarr.py"", line 534, in store self.set_variables( File ""/Users/tom/miniconda/envs/sgkit-3.8/lib/python3.8/site-packages/xarray/backends/zarr.py"", line 581, in set_variables encoding = extract_zarr_variable_encoding( File ""/Users/tom/miniconda/envs/sgkit-3.8/lib/python3.8/site-packages/xarray/backends/zarr.py"", line 220, in extract_zarr_variable_encoding raise ValueError( ValueError: unexpected encoding parameters for zarr backend: ['write_empty_chunks'] ``` ### Anything else we need to know? _No response_ ### Environment INSTALLED VERSIONS ------------------ commit: None python: 3.8.12 (default, Oct 12 2021, 06:23:56) [Clang 10.0.0 ] python-bits: 64 OS: Darwin OS-release: 19.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: ('en_GB', 'UTF-8') libhdf5: None libnetcdf: None xarray: 2022.3.0 pandas: 1.3.5 numpy: 1.21.5 scipy: 1.7.3 netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: 2.11.0 cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2022.01.0 distributed: 2022.01.0 matplotlib: 3.5.1 cartopy: None seaborn: 0.11.2 numbagg: None fsspec: 2022.01.0 cupy: None pint: None sparse: None setuptools: 58.0.4 pip: 21.2.4 conda: None pytest: 6.2.5 IPython: 8.0.1 sphinx: 4.2.0","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6347/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue