Skip to content

Commit 05049de

Browse files
DimitriPapadopoulosFrancescAlted
authored andcommitted
Fix alerts detected by newer ruff 0.1.7
1 parent f1b6713 commit 05049de

File tree

9 files changed

+14
-16
lines changed

9 files changed

+14
-16
lines changed

bench/pack_tensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
ctoc = time.time()
4949
tc = (ctoc - ctic) / NREP
5050
print(
51-
" Time for tensorflow (tf.io.serialize):\t[:.3f} s ({:.2f} GB/s)) ".format(tc, ((N * 8 / tc) / 2**30)),
51+
" Time for tensorflow (tf.io.serialize):\t{:.3f} s ({:.2f} GB/s)) ".format(tc, ((N * 8 / tc) / 2**30)),
5252
end="",
5353
)
5454
print("\tcr: {:5.1f}x".format(in_.size * in_.dtype.itemsize * 1.0 / len(c)))

blosc2/core.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,13 +1115,14 @@ def get_chunksize(blocksize, l3_minimum=2**21, l3_maximum=2**25):
11151115
# value only when it is an actual int.
11161116
# Also, sometimes cpuinfo does not return a correct L3 size;
11171117
# so in general, enforcing L3 > L2 is a good sanity check.
1118-
l2_cache_size = cpu_info.get("l2_cache_size", "Not found")
1119-
if type(l3_cache_size) is int and type(l2_cache_size) is int and l3_cache_size > l2_cache_size:
1120-
chunksize = l3_cache_size
1118+
if isinstance(l3_cache_size, int):
1119+
l2_cache_size = cpu_info.get("l2_cache_size", "Not found")
1120+
if isinstance(l2_cache_size, int) and l3_cache_size > l2_cache_size:
1121+
chunksize = l3_cache_size
11211122
else:
11221123
# Chunksize should be at least the size of L2
11231124
l2_cache_size = cpu_info.get("l2_cache_size", "Not found")
1124-
if type(l2_cache_size) is int and l2_cache_size > chunksize:
1125+
if isinstance(l2_cache_size, int) and l2_cache_size > chunksize:
11251126
chunksize = l2_cache_size
11261127

11271128
# Ensure a minimum size

blosc2/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def info_text_report(items: list) -> str:
2222
max_key_len = max(len(k) for k in keys)
2323
report = ""
2424
for k, v in items:
25-
if type(v) is dict:
25+
if isinstance(v, dict):
2626
# rich way, this is disabled because it doesn't work well in the notebooks
2727
# with io.StringIO() as buf:
2828
# v_sorted = {k: val for k, val in sorted(v.items())}

blosc2/ndarray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,9 @@ def squeeze(self):
368368

369369

370370
def _check_shape(shape):
371-
if type(shape) is int:
371+
if isinstance(shape, int):
372372
shape = (shape,)
373-
if type(shape) not in (tuple, list):
373+
elif not isinstance(shape, (tuple, list)):
374374
raise ValueError("shape should be a tuple or a list!")
375375
return shape
376376

examples/btune.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
# Set the Btune configuration to use
3030
btune_conf = {"tradeoff": 0.3, "perf_mode": blosc2_btune.PerformanceMode.DECOMP}
31-
blosc2_btune.set_params_defaults(**kwargs)
31+
blosc2_btune.set_params_defaults()
3232

3333
# Create the SChunk
3434
data = np.arange(200 * 1000 * nchunks)

tests/test_compress2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def test_raise_error(object, cparams, dparams, gil):
109109
blosc2.decompress2(c, dst=dest)
110110

111111
dest3 = blosc2.decompress2(c)
112-
if type(object) is bytes:
112+
if isinstance(object, bytes):
113113
assert dest3 == object
114114
else:
115115
assert dest3 == object.tobytes()

tests/test_decompress.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ def test_raise_error(object, codec):
8383
blosc2.decompress(c, dst=dest)
8484

8585
dest3 = blosc2.decompress(c)
86-
if type(object) is bytes:
86+
if isinstance(object, bytes):
8787
assert dest3 == object
8888
else:
8989
assert dest3 == object.tobytes()
9090

9191
dest4 = blosc2.decompress(c, as_bytearray=True)
92-
if type(object) is bytes:
92+
if isinstance(object, bytes):
9393
assert dest4 == object
9494
else:
9595
assert dest4 == object.tobytes()

tests/test_pathlib.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
# LICENSE file in the root directory of this source tree)
77
#######################################################################
88

9-
import os
10-
119
import numpy as np
1210
import pytest
1311
import pathlib

tests/test_ucodecs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,10 @@ def test_dynamic_ucodecs_error(cparams, dparams):
142142
chunk_len = 100
143143
dtype = np.dtype(np.int32)
144144
nchunks = 1
145-
fill_value = 341
146145
data = np.arange(chunk_len * nchunks, dtype=dtype)
147146

148147
with pytest.raises(RuntimeError):
149-
schunk = blosc2.SChunk(
148+
_ = blosc2.SChunk(
150149
chunksize=chunk_len * dtype.itemsize,
151150
data=data,
152151
cparams=cparams,

0 commit comments

Comments
 (0)