diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index b6188214b7e..1c8a24770d7 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -5350,6 +5350,40 @@ def test_zarr_region_index_write(self, tmp_path): assert "x" not in written_variables assert "y" not in written_variables + def test_zarr_region_append(self, tmp_path): + x = np.arange(0, 50, 10) + y = np.arange(0, 20, 2) + data = np.ones((5, 10)) + ds = xr.Dataset( + { + "test": xr.DataArray( + data, + dims=("x", "y"), + coords={"x": x, "y": y}, + ) + } + ) + ds.to_zarr(tmp_path / "test.zarr") + + x_new = np.arange(40, 70, 10) + data_new = np.ones((3, 10)) + ds_new = xr.Dataset( + { + "test": xr.DataArray( + data_new, + dims=("x", "y"), + coords={"x": x_new, "y": y}, + ) + } + ) + + # Don't allow auto region detection in append mode due to complexities in + # implementing the overlap logic and lack of safety with parallel writes + with pytest.raises(ValueError): + ds_new.to_zarr( + tmp_path / "test.zarr", mode="a", append_dim="x", region="auto" + ) + @requires_zarr def test_zarr_region_transpose(tmp_path):