Skip to content

Commit 4194bdf

Browse files
style: pre-commit fixes
1 parent 31c61d3 commit 4194bdf

28 files changed

+10
-310
lines changed

bench/compress_normal.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from zarr import blosc
99

1010
if __name__ == "__main__":
11-
1211
sys.path.insert(0, "..")
1312

1413
# setup

zarr/_storage/absstore.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __init__(
8787
"https://{}.blob.core.windows.net/".format(account_name),
8888
container,
8989
credential=account_key,
90-
**blob_service_kwargs
90+
**blob_service_kwargs,
9191
)
9292

9393
self.client = client
@@ -240,7 +240,6 @@ def __setitem__(self, key, value):
240240
super().__setitem__(key, value)
241241

242242
def rmdir(self, path=None):
243-
244243
if not path:
245244
# Currently allowing clear to delete everything as in v2
246245

zarr/_storage/store.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ def _rmdir_from_keys(store: StoreLike, path: Optional[str] = None) -> None:
629629

630630

631631
def _rmdir_from_keys_v3(store: StoreV3, path: str = "") -> None:
632-
633632
meta_dir = meta_root + path
634633
meta_dir = meta_dir.rstrip("/")
635634
_rmdir_from_keys(store, meta_dir)

zarr/_storage/v3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ def _get_files_and_dirs_from_path(store, path):
118118

119119

120120
class FSStoreV3(FSStore, StoreV3):
121-
122121
# FSStoreV3 doesn't use this (FSStore uses it within _normalize_key)
123122
_META_KEYS = ()
124123

zarr/attrs.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class Attributes(MutableMapping):
2626
"""
2727

2828
def __init__(self, store, key=".zattrs", read_only=False, cache=True, synchronizer=None):
29-
3029
self._version = getattr(store, "_store_version", 2)
3130
_Store = Store if self._version == 2 else StoreV3
3231
self.store = _Store._ensure_store(store)
@@ -73,7 +72,6 @@ def __getitem__(self, item):
7372
return self.asdict()[item]
7473

7574
def _write_op(self, f, *args, **kwargs):
76-
7775
# guard condition
7876
if self.read_only:
7977
raise PermissionError("attributes are read-only")
@@ -89,7 +87,6 @@ def __setitem__(self, item, value):
8987
self._write_op(self._setitem_nosync, item, value)
9088

9189
def _setitem_nosync(self, item, value):
92-
9390
# load existing data
9491
d = self._get_nosync()
9592

@@ -106,7 +103,6 @@ def __delitem__(self, item):
106103
self._write_op(self._delitem_nosync, item)
107104

108105
def _delitem_nosync(self, key):
109-
110106
# load existing data
111107
d = self._get_nosync()
112108

@@ -128,7 +124,6 @@ def put(self, d):
128124
self._write_op(self._put_nosync, dict(attributes=d))
129125

130126
def _put_nosync(self, d):
131-
132127
d_to_check = d if self._version == 2 else d["attributes"]
133128
if not all(isinstance(item, str) for item in d_to_check):
134129
# TODO: Raise an error for non-string keys
@@ -178,7 +173,6 @@ def update(self, *args, **kwargs):
178173
self._write_op(self._update_nosync, *args, **kwargs)
179174

180175
def _update_nosync(self, *args, **kwargs):
181-
182176
# load existing data
183177
d = self._get_nosync()
184178

zarr/convenience.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,8 @@ def copy_store(
674674

675675
# setup logging
676676
with _LogWriter(log) as log:
677-
678677
# iterate over source keys
679678
for source_key in sorted(source.keys()):
680-
681679
# filter to keys under source path
682680
if source_store_version == 2:
683681
if not source_key.startswith(source_path):
@@ -756,7 +754,7 @@ def copy(
756754
log=None,
757755
if_exists="raise",
758756
dry_run=False,
759-
**create_kws
757+
**create_kws,
760758
):
761759
"""Copy the `source` array or group into the `dest` group.
762760
@@ -877,7 +875,6 @@ def copy(
877875

878876
# setup logging
879877
with _LogWriter(log) as log:
880-
881878
# do the copying
882879
n_copied, n_skipped, n_bytes_copied = _copy(
883880
log,
@@ -889,7 +886,7 @@ def copy(
889886
without_attrs=without_attrs,
890887
if_exists=if_exists,
891888
dry_run=dry_run,
892-
**create_kws
889+
**create_kws,
893890
)
894891

895892
# log a final message with a summary of what happened
@@ -947,12 +944,10 @@ def _copy(log, source, dest, name, root, shallow, without_attrs, if_exists, dry_
947944

948945
# take action
949946
if do_copy:
950-
951947
# log a message about what we're going to do
952948
log("copy {} {} {}".format(source.name, source.shape, source.dtype))
953949

954950
if not dry_run:
955-
956951
# clear the way
957952
if exists:
958953
del dest[name]
@@ -1037,12 +1032,10 @@ def _copy(log, source, dest, name, root, shallow, without_attrs, if_exists, dry_
10371032

10381033
# take action
10391034
if do_copy:
1040-
10411035
# log action
10421036
log("copy {}".format(source.name))
10431037

10441038
if not dry_run:
1045-
10461039
# clear the way
10471040
if exists_array:
10481041
del dest[name]
@@ -1055,7 +1048,6 @@ def _copy(log, source, dest, name, root, shallow, without_attrs, if_exists, dry_
10551048
grp.attrs.update(source.attrs)
10561049

10571050
else:
1058-
10591051
# setup for dry run without creating any groups in the
10601052
# destination
10611053
if dest is not None:
@@ -1075,7 +1067,7 @@ def _copy(log, source, dest, name, root, shallow, without_attrs, if_exists, dry_
10751067
without_attrs=without_attrs,
10761068
if_exists=if_exists,
10771069
dry_run=dry_run,
1078-
**create_kws
1070+
**create_kws,
10791071
)
10801072
n_copied += c
10811073
n_skipped += s
@@ -1098,7 +1090,7 @@ def copy_all(
10981090
log=None,
10991091
if_exists="raise",
11001092
dry_run=False,
1101-
**create_kws
1093+
**create_kws,
11021094
):
11031095
"""Copy all children of the `source` group into the `dest` group.
11041096
@@ -1188,7 +1180,6 @@ def copy_all(
11881180

11891181
# setup logging
11901182
with _LogWriter(log) as log:
1191-
11921183
for k in source.keys():
11931184
c, s, b = _copy(
11941185
log,
@@ -1200,7 +1191,7 @@ def copy_all(
12001191
without_attrs=without_attrs,
12011192
if_exists=if_exists,
12021193
dry_run=dry_run,
1203-
**create_kws
1194+
**create_kws,
12041195
)
12051196
n_copied += c
12061197
n_skipped += s
@@ -1261,7 +1252,6 @@ def is_zarr_key(key):
12611252
return key.endswith(".zarray") or key.endswith(".zgroup") or key.endswith(".zattrs")
12621253

12631254
else:
1264-
12651255
assert_zarr_v3_api_available()
12661256

12671257
sfx = _get_metadata_suffix(store) # type: ignore

zarr/core.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ def _load_metadata_nosync(self):
253253
except KeyError:
254254
raise ArrayNotFoundError(self._path)
255255
else:
256-
257256
# decode and store metadata as instance members
258257
meta = self._store._metadata_class.decode_array_metadata(meta_bytes)
259258
self._meta = meta
@@ -1358,7 +1357,6 @@ def get_mask_selection(self, selection, out=None, fields=None):
13581357
return self._get_selection(indexer=indexer, out=out, fields=fields)
13591358

13601359
def _get_selection(self, indexer, out=None, fields=None):
1361-
13621360
# We iterate over all chunks which overlap the selection and thus contain data
13631361
# that needs to be extracted. Each chunk is processed in turn, extracting the
13641362
# necessary data and storing into the correct location in the output array.
@@ -1983,7 +1981,6 @@ def _set_basic_selection_nd(self, selection, value, fields=None):
19831981
self._set_selection(indexer, value, fields=fields)
19841982

19851983
def _set_selection(self, indexer, value, fields=None):
1986-
19871984
# We iterate over all chunks which overlap the selection and thus contain data
19881985
# that needs to be replaced. Each chunk is processed in turn, extracting the
19891986
# necessary data from the value array and storing into the chunk array.
@@ -2018,7 +2015,6 @@ def _set_selection(self, indexer, value, fields=None):
20182015
):
20192016
# iterative approach
20202017
for chunk_coords, chunk_selection, out_selection in indexer:
2021-
20222018
# extract data to store
20232019
if sel_shape == ():
20242020
chunk_value = value
@@ -2077,7 +2073,6 @@ def _process_chunk(
20772073
and not self._filters
20782074
and self._dtype != object
20792075
):
2080-
20812076
dest = out[out_selection]
20822077
# Assume that array-like objects that doesn't have a
20832078
# `writeable` flag is writable.
@@ -2088,7 +2083,6 @@ def _process_chunk(
20882083
)
20892084

20902085
if write_direct:
2091-
20922086
# optimization: we want the whole chunk, and the destination is
20932087
# contiguous, so we can decompress directly from the chunk
20942088
# into the destination array
@@ -2321,28 +2315,24 @@ def _process_for_setitem(self, ckey, chunk_selection, value, fields=None):
23212315
# to access the existing chunk data
23222316

23232317
if is_scalar(value, self._dtype):
2324-
23252318
# setup array filled with value
23262319
chunk = np.empty_like(
23272320
self._meta_array, shape=self._chunks, dtype=self._dtype, order=self._order
23282321
)
23292322
chunk.fill(value)
23302323

23312324
else:
2332-
23332325
# ensure array is contiguous
23342326
chunk = value.astype(self._dtype, order=self._order, copy=False)
23352327

23362328
else:
23372329
# partially replace the contents of this chunk
23382330

23392331
try:
2340-
23412332
# obtain compressed data for chunk
23422333
cdata = self.chunk_store[ckey]
23432334

23442335
except KeyError:
2345-
23462336
# chunk not initialized
23472337
if self._fill_value is not None:
23482338
chunk = np.empty_like(
@@ -2359,7 +2349,6 @@ def _process_for_setitem(self, ckey, chunk_selection, value, fields=None):
23592349
)
23602350

23612351
else:
2362-
23632352
# decode chunk
23642353
chunk = self._decode_chunk(cdata)
23652354
if not chunk.flags.writeable:
@@ -2429,7 +2418,6 @@ def _decode_chunk(self, cdata, start=None, nitems=None, expected_shape=None):
24292418
return chunk
24302419

24312420
def _encode_chunk(self, chunk):
2432-
24332421
# apply filters
24342422
if self._filters:
24352423
for f in self._filters:
@@ -2619,7 +2607,6 @@ def __setstate__(self, state):
26192607
self.__init__(**state)
26202608

26212609
def _synchronized_op(self, f, *args, **kwargs):
2622-
26232610
if self._synchronizer is None:
26242611
# no synchronization
26252612
lock = nolock
@@ -2636,7 +2623,6 @@ def _synchronized_op(self, f, *args, **kwargs):
26362623
return result
26372624

26382625
def _write_op(self, f, *args, **kwargs):
2639-
26402626
# guard condition
26412627
if self._read_only:
26422628
raise ReadOnlyError()
@@ -2676,7 +2662,6 @@ def resize(self, *args):
26762662
return self._write_op(self._resize_nosync, *args)
26772663

26782664
def _resize_nosync(self, *args):
2679-
26802665
# normalize new shape argument
26812666
old_shape = self._shape
26822667
new_shape = normalize_resize_args(old_shape, *args)
@@ -2755,7 +2740,6 @@ def append(self, data, axis=0):
27552740
return self._write_op(self._append_nosync, data, axis=axis)
27562741

27572742
def _append_nosync(self, data, axis=0):
2758-
27592743
# ensure data is array-like
27602744
if not hasattr(data, "shape"):
27612745
data = np.asanyarray(data, like=self._meta_array)

zarr/creation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ def create(
234234

235235

236236
def _kwargs_compat(compressor, fill_value, kwargs):
237-
238237
# to be compatible with h5py, as well as backwards-compatible with Zarr
239238
# 1.x, accept 'compression' and 'compression_opts' keyword arguments
240239

@@ -697,7 +696,6 @@ def open_array(
697696

698697

699698
def _like_args(a, kwargs):
700-
701699
shape, chunks = _get_shape_chunks(a)
702700
if shape is not None:
703701
kwargs.setdefault("shape", shape)

0 commit comments

Comments
 (0)