Skip to content

Commit 3cb1f33

Browse files
committed
Format
1 parent cc335c7 commit 3cb1f33

File tree

6 files changed

+36
-33
lines changed

6 files changed

+36
-33
lines changed

zarr/_storage/store.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,7 @@ def _validate_key(self, key: str):
222222
)
223223

224224
if (
225-
not key.startswith(("data/", "meta/"))
226-
and key != "zarr.json"
225+
not key.startswith(("data/", "meta/")) and key != "zarr.json"
227226
# TODO: Possibly allow key == ".zmetadata" too if we write a
228227
# consolidated metadata spec corresponding to this?
229228
):

zarr/hierarchy.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -591,27 +591,33 @@ def groups(self):
591591
for key in sorted(listdir(self._store, self._path)):
592592
path = self._key_prefix + key
593593
if contains_group(self._store, path, explicit_only=False):
594-
yield key, Group(
594+
yield (
595+
key,
596+
Group(
597+
self._store,
598+
path=path,
599+
read_only=self._read_only,
600+
chunk_store=self._chunk_store,
601+
cache_attrs=self.attrs.cache,
602+
synchronizer=self._synchronizer,
603+
zarr_version=self._version,
604+
),
605+
)
606+
607+
else:
608+
for key in self.group_keys():
609+
path = self._key_prefix + key
610+
yield (
611+
key,
612+
Group(
595613
self._store,
596614
path=path,
597615
read_only=self._read_only,
598616
chunk_store=self._chunk_store,
599617
cache_attrs=self.attrs.cache,
600618
synchronizer=self._synchronizer,
601619
zarr_version=self._version,
602-
)
603-
604-
else:
605-
for key in self.group_keys():
606-
path = self._key_prefix + key
607-
yield key, Group(
608-
self._store,
609-
path=path,
610-
read_only=self._read_only,
611-
chunk_store=self._chunk_store,
612-
cache_attrs=self.attrs.cache,
613-
synchronizer=self._synchronizer,
614-
zarr_version=self._version,
620+
),
615621
)
616622

617623
def array_keys(self, recurse=False):

zarr/indexing.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,9 @@ def __init__(self, dim_sel, dim_len, dim_chunk_len):
370370
# check shape
371371
if dim_sel.shape[0] != dim_len:
372372
raise IndexError(
373-
"Boolean array has the wrong length for dimension; "
374-
"expected {}, got {}".format(dim_len, dim_sel.shape[0])
373+
"Boolean array has the wrong length for dimension; " "expected {}, got {}".format(
374+
dim_len, dim_sel.shape[0]
375+
)
375376
)
376377

377378
# store attributes
@@ -919,8 +920,9 @@ def check_fields(fields, dtype):
919920
# check type
920921
if not isinstance(fields, (str, list, tuple)):
921922
raise IndexError(
922-
"'fields' argument must be a string or list of strings; found "
923-
"{!r}".format(type(fields))
923+
"'fields' argument must be a string or list of strings; found " "{!r}".format(
924+
type(fields)
925+
)
924926
)
925927
if fields:
926928
if dtype.names is None:

zarr/storage.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,9 +2704,7 @@ def listdir(self, path=None):
27042704
SELECT LTRIM(SUBSTR(k, LENGTH(?) + 1), "/") || "/" AS m
27052705
FROM zarr WHERE k LIKE (? || "{sep}%")
27062706
) ORDER BY l ASC
2707-
""".format(
2708-
sep=sep
2709-
),
2707+
""".format(sep=sep),
27102708
(path, path),
27112709
)
27122710
keys = list(map(operator.itemgetter(0), keys))

zarr/tests/test_meta.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,7 @@ def test_decode_array_unsupported_format():
495495
"compressor": {"id": "zlib", "level": 1},
496496
"fill_value": null,
497497
"order": "C"
498-
}""" % (
499-
ZARR_FORMAT - 1
500-
)
498+
}""" % (ZARR_FORMAT - 1)
501499
with pytest.raises(MetadataError):
502500
decode_array_metadata(meta_json)
503501

@@ -537,9 +535,7 @@ def test_decode_group():
537535
# unsupported format
538536
b = """{
539537
"zarr_format": %s
540-
}""" % (
541-
ZARR_FORMAT - 1
542-
)
538+
}""" % (ZARR_FORMAT - 1)
543539
with pytest.raises(MetadataError):
544540
decode_group_metadata(b)
545541

zarr/util.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,9 @@ def normalize_fill_value(fill_value, dtype: np.dtype):
307307

308308
if not isinstance(fill_value, str):
309309
raise ValueError(
310-
"fill_value {!r} is not valid for dtype {}; must be a "
311-
"unicode string".format(fill_value, dtype)
310+
"fill_value {!r} is not valid for dtype {}; must be a " "unicode string".format(
311+
fill_value, dtype
312+
)
312313
)
313314

314315
else:
@@ -322,8 +323,9 @@ def normalize_fill_value(fill_value, dtype: np.dtype):
322323
except Exception as e:
323324
# re-raise with our own error message to be helpful
324325
raise ValueError(
325-
"fill_value {!r} is not valid for dtype {}; nested "
326-
"exception: {}".format(fill_value, dtype, e)
326+
"fill_value {!r} is not valid for dtype {}; nested " "exception: {}".format(
327+
fill_value, dtype, e
328+
)
327329
)
328330

329331
return fill_value

0 commit comments

Comments
 (0)