Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 18, 2024
1 parent 85c49d3 commit 0160d48
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 9 additions & 2 deletions xarray/backends/zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ def _determine_zarr_chunks(enc_chunks, var_chunks, ndim, name, safe_chunks, regi
f"or modifying `encoding['chunks']`, or specify `safe_chunks=False`."
)

for zchunk, dchunks, interval in zip(enc_chunks_tuple, var_chunks, region, strict=True):
for zchunk, dchunks, interval in zip(
enc_chunks_tuple, var_chunks, region, strict=True
):
if not safe_chunks or len(dchunks) <= 1:
# It is not necessary to perform any additional validation if the
# safe_chunks is False, or there are less than two dchunks
Expand Down Expand Up @@ -302,7 +304,12 @@ def extract_zarr_variable_encoding(
del encoding[k]

chunks = _determine_zarr_chunks(
encoding.get("chunks"), variable.chunks, variable.ndim, name, safe_chunks, region
encoding.get("chunks"),
variable.chunks,
variable.ndim,
name,
safe_chunks,
region,
)
encoding["chunks"] = chunks
return encoding
Expand Down
4 changes: 1 addition & 3 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -6149,7 +6149,5 @@ def test_zarr_safe_chunk(tmp_path):
da.isel(x=slice(0, 7)).to_zarr(store, safe_chunks=True, mode="w")
# Append with a single chunk it's totally valid,
# and it does not matter the size of the chunk
da.isel(x=slice(7, 19)).chunk(x=-1).to_zarr(
store, append_dim="x", safe_chunks=True
)
da.isel(x=slice(7, 19)).chunk(x=-1).to_zarr(store, append_dim="x", safe_chunks=True)
assert xr.open_zarr(store)["foo"].equals(da.isel(x=slice(0, 19)))

0 comments on commit 0160d48

Please sign in to comment.