Skip to content
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

Apply assorted ruff/refurb rules (FURB) #1707

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion zarr/_storage/v3_storage_transformers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import functools
import itertools
import operator
import os
from typing import NamedTuple, Tuple, Optional, Union, Iterator

Expand Down Expand Up @@ -101,7 +102,7 @@ def __init__(self, _type, chunks_per_shard) -> None:
if chunks_per_shard == ():
chunks_per_shard = (1,)
self.chunks_per_shard = chunks_per_shard
self._num_chunks_per_shard = functools.reduce(lambda x, y: x * y, chunks_per_shard, 1)
self._num_chunks_per_shard = functools.reduce(operator.mul, chunks_per_shard, 1)
self._dimension_separator = None
self._data_key_prefix = None

Expand Down
4 changes: 2 additions & 2 deletions zarr/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def decode_fill_value(cls, v: Any, dtype: np.dtype, object_codec: Any = None) ->
return -np.inf
else:
return np.array(v, dtype=dtype)[()]
elif dtype.kind in "c":
elif dtype.kind == "c":
v = (
cls.decode_fill_value(v[0], dtype.type().real.dtype),
cls.decode_fill_value(v[1], dtype.type().imag.dtype),
Expand Down Expand Up @@ -283,7 +283,7 @@ def encode_fill_value(cls, v: Any, dtype: np.dtype, object_codec: Any = None) ->
return int(v)
elif dtype.kind == "b":
return bool(v)
elif dtype.kind in "c":
elif dtype.kind == "c":
c = cast(np.complex128, np.dtype(complex).type())
v = (
cls.encode_fill_value(v.real, c.real.dtype, object_codec),
Expand Down
4 changes: 1 addition & 3 deletions zarr/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1995,9 +1995,7 @@ def test_attrs_n5_keywords(self):
def test_compressors(self):
compressors = [None, BZ2(), Zlib(), GZip(), MsgPack()]
if LZMA:
compressors.append(LZMA())
compressors.append(LZMA(preset=1))
compressors.append(LZMA(preset=6))
compressors.extend((LZMA(), LZMA(preset=1), LZMA(preset=6)))
for compressor in compressors:
a1 = self.create_array(shape=1000, chunks=100, compressor=compressor)
a1[0:100] = 1
Expand Down