Skip to content

Commit 2c8f2e8

Browse files
committed
add ValueError
1 parent dbb98b4 commit 2c8f2e8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

xarray/core/dataarray.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,11 @@ def chunk(
14441444
"It will raise an error in the future. Instead use a dict with dimension names as keys.",
14451445
category=DeprecationWarning,
14461446
)
1447+
if len(chunks) != len(self.dims):
1448+
raise ValueError(
1449+
f"chunks must have the same number of elements as dimensions. "
1450+
f"Expected {len(self.dims)} elements, got {len(chunks)}."
1451+
)
14471452
chunk_mapping = dict(zip(self.dims, chunks, strict=True))
14481453
else:
14491454
chunk_mapping = either_dict_or_kwargs(chunks, chunks_kwargs, "chunk")

0 commit comments

Comments
 (0)