Skip to content

Commit 1ed4ef1

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 9cfcc41 commit 1ed4ef1

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

xarray/backends/zarr.py

+19-12
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
from xarray.core.datatree import DataTree
4444

4545

46-
4746
@functools.lru_cache
4847
def _zarr_v3() -> bool:
4948
try:
@@ -89,8 +88,10 @@ def __init__(self, zarr_array):
8988
self.shape = self._array.shape
9089

9190
# preserve vlen string object dtype (GH 7328)
92-
if not _zarr_v3() and self._array.filters is not None and any(
93-
[filt.codec_id == "vlen-utf8" for filt in self._array.filters]
91+
if (
92+
not _zarr_v3()
93+
and self._array.filters is not None
94+
and any([filt.codec_id == "vlen-utf8" for filt in self._array.filters])
9495
):
9596
dtype = coding.strings.create_vlen_dtype(str)
9697
else:
@@ -633,17 +634,23 @@ def open_store_variable(self, name, zarr_array=None):
633634
}
634635

635636
if _zarr_v3() and zarr_array.metadata.zarr_format == 3:
636-
encoding["codec_pipeline"] = [x.to_dict() for x in zarr_array.metadata.codecs]
637+
encoding["codec_pipeline"] = [
638+
x.to_dict() for x in zarr_array.metadata.codecs
639+
]
637640
elif _zarr_v3():
638-
encoding.update({
639-
"compressor": zarr_array.metadata.compressor,
640-
"filters": zarr_array.metadata.filters,
641-
})
641+
encoding.update(
642+
{
643+
"compressor": zarr_array.metadata.compressor,
644+
"filters": zarr_array.metadata.filters,
645+
}
646+
)
642647
else:
643-
encoding.update({
644-
"compressor": zarr_array.compressor,
645-
"filters": zarr_array.filters,
646-
})
648+
encoding.update(
649+
{
650+
"compressor": zarr_array.compressor,
651+
"filters": zarr_array.filters,
652+
}
653+
)
647654

648655
# _FillValue needs to be in attributes, not encoding, so it will get
649656
# picked up by decode_cf

xarray/tests/test_backends.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,9 @@ def test_roundtrip_consolidated(self, consolidated) -> None:
22552255
def test_read_non_consolidated_warning(self) -> None:
22562256
expected = create_test_data()
22572257
with self.create_zarr_target() as store:
2258-
self.save(expected, store_target=store, consolidated=False, **self.version_kwargs)
2258+
self.save(
2259+
expected, store_target=store, consolidated=False, **self.version_kwargs
2260+
)
22592261
with pytest.warns(
22602262
RuntimeWarning,
22612263
match="Failed to open Zarr store with consolidated",
@@ -3044,7 +3046,12 @@ def test_encoding_chunksizes(self) -> None:
30443046
# see also test_encoding_chunksizes_unlimited
30453047
nx, ny, nt = 4, 4, 5
30463048
original = xr.Dataset(
3047-
{}, coords={"x": np.arange(nx) + 1 , "y": np.arange(ny) + 1, "t": np.arange(nt) + 1}
3049+
{},
3050+
coords={
3051+
"x": np.arange(nx) + 1,
3052+
"y": np.arange(ny) + 1,
3053+
"t": np.arange(nt) + 1,
3054+
},
30483055
)
30493056
original["v"] = xr.Variable(("x", "y", "t"), np.zeros((nx, ny, nt)))
30503057
original = original.chunk({"t": 1, "x": 2, "y": 2})
@@ -3304,6 +3311,7 @@ class TestZarrDictStore(ZarrBase):
33043311
def create_zarr_target(self):
33053312
if have_zarr_v3:
33063313
import zarr.store
3314+
33073315
yield zarr.store.MemoryStore({}, mode="w")
33083316
else:
33093317
yield {}

0 commit comments

Comments
 (0)