8000 Raise `ValueError` for unmatching chunks length in `DataArray.chunk()` by lkstrp · Pull Request #9689 · pydata/xarray · GitHub
[go: up one dir, main page]

Skip to content

Raise ValueError for unmatching chunks length in DataArray.chunk() #9689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add ValueError
  • Loading branch information
lkstrp committed Oct 28, 2024
commit 2c8f2e81e2ac8c49cbdad86367c571cfef9cdba7
5 changes: 5 additions & 0 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,11 @@ def chunk(
"It will raise an error in the future. Instead use a dict with dimension names as keys.",
category=DeprecationWarning,
)
if len(chunks) != len(self.dims):
raise ValueError(
f"chunks must have the same number of elements as dimensions. "
f"Expected {len(self.dims)} elements, got {len(chunks)}."
)
chunk_mapping = dict(zip(self.dims, chunks, strict=True))
else:
chunk_mapping = either_dict_or_kwargs(chunks, chunks_kwargs, "chunk")
Expand Down
Loading
0