Skip to content

Commit c7327f3

Browse files
committed
Some fixes
1 parent c82c6bd commit c7327f3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

xarray/backends/zarr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from xarray.backends.store import StoreBackendEntrypoint
2222
from xarray.core import indexing
2323
from xarray.core.parallelcompat import guess_chunkmanager
24-
from xarray.core.pycompat import integer_types
24+
from xarray.core.pycompat import integer_types, is_chunked_array
2525
from xarray.core.types import ZarrWriteModes
2626
from xarray.core.utils import (
2727
FrozenDict,
@@ -46,7 +46,7 @@ def initialize_zarr(
4646
ds: Dataset,
4747
store: MutableMapping | None = None,
4848
*,
49-
region_dims: Iterable[Hashable] | None = None,
49+
region_dims: Iterable[Hashable] = tuple(),
5050
mode: Literal["w", "w-"] = "w-",
5151
consolidated: bool | None = None,
5252
zarr_version: int | None = None,
@@ -90,7 +90,7 @@ def initialize_zarr(
9090
if "compute" in kwargs:
9191
raise ValueError("The ``compute`` kwarg is not supported in `initialize_zarr`.")
9292

93-
if not ds.chunks:
93+
if not any(is_chunked_array(v._data) for v in ds._variables.values()):
9494
raise ValueError("This function should be used with chunked Datasets.")
9595

9696
if mode not in ["w", "w-"]:

xarray/tests/test_backends.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5490,6 +5490,7 @@ def test_initialize_zarr(tmp_path) -> None:
54905490
# 4. mode = r?
54915491
# 5. mode=w+?
54925492
# 5. no region_dims
5493+
# different chunksizes along same dimension
54935494
x = np.arange(0, 50, 10)
54945495
y = np.arange(0, 20, 2)
54955496
data = dask.array.ones((5, 10), chunks=(1, -1))

0 commit comments

Comments
 (0)