Skip to content

Commit

Permalink
test that auto append fails
Browse files Browse the repository at this point in the history
  • Loading branch information
slevang committed Nov 14, 2023
1 parent 809e9e8 commit 9eb1b58
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 9eb1b58

Please sign in to comment.