-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
What happened?
Even though it was fixed in #10177, write_empty_chunks
seems to be ignored. When I write to an by xarray created zarr (no matter if a zarr format 2 or 3) with a defined fill_value of 0, a completely 0 filled chunk is not written while a chunk with data is written. Setting write_empty_chunks to True does not change this behaviour.
What did you expect to happen?
An empty chunk should be created, but there is None.
Minimal Complete Verifiable Example
import dask.array
import xarray as xr
import numpy as np
path = "test.zarr"
# create empty zarr
dummies = dask.array.zeros(30, chunks=10)
ds = xr.Dataset({"foo": ("x", dummies)}, coords={"x": np.arange(30)})
ds.to_zarr(path, compute=False)
# create dataset containing only fill_value
random_data = np.zeros((10))
ds = xr.Dataset({"foo": ("x", random_data)}, coords={"x": np.arange(10)})
# should write empty chunks, but foo has no written chunks afterwards
ds.to_zarr(path, region={'x': slice(0,10)}, write_empty_chunks=True)
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, returning the result.
- New issue — a search of GitHub Issues suggests this is not a duplicate.
- Recent environment — the issue occurs with the latest version of xarray and its dependencies.
Relevant log output
Anything else we need to know?
No response
Environment
INSTALLED VERSIONS
commit: None
python: 3.12.3 | packaged by Anaconda, Inc. | (main, May 6 2024, 19:46:43) [GCC 11.2.0]
python-bits: 64
OS: Linux
OS-release: 6.8.0-65-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.14.4
libnetcdf: None
xarray: 2025.7.1
pandas: 2.2.3
numpy: 2.3.2
scipy: 1.15.1
netCDF4: None
pydap: None
h5netcdf: 1.5.0
h5py: 3.12.1
zarr: 3.1.1
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: 2025.1.0
distributed: None
matplotlib: 3.9.2
cartopy: None
seaborn: 0.13.2
numbagg: None
fsspec: 2025.3.0
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 80.9.0
pip: 25.0.1
conda: 24.4.0
pytest: 8.3.2
mypy: 1.10.1
IPython: 8.26.0
sphinx: None
None