Skip to content

Commit 308caf3

Browse files
committed
Apply ruff
1 parent 16cc9b3 commit 308caf3

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

numcodecs/tests/test_pyzstd.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,41 @@
1313
pyzstd = pytest.importorskip("pyzstd")
1414

1515
test_data = [
16-
b"Hello World!",
17-
np.arange(113).tobytes(),
18-
np.arange(10,15).tobytes(),
19-
np.random.randint(3, 50, size=(53,)).tobytes()
16+
b"Hello World!",
17+
np.arange(113).tobytes(),
18+
np.arange(10, 15).tobytes(),
19+
np.random.randint(3, 50, size=(53,)).tobytes(),
2020
]
2121

22+
2223
@pytest.mark.parametrize("input", test_data)
2324
def test_pyzstd_simple(input):
2425
z = Zstd()
2526
assert z.decode(pyzstd.compress(input)) == input
2627
assert pyzstd.decompress(z.encode(input)) == input
2728

29+
2830
@pytest.mark.xfail
2931
@pytest.mark.parametrize("input", test_data)
3032
def test_pyzstd_simple_multiple_frames(input):
3133
z = Zstd()
32-
assert z.decode(pyzstd.compress(input)*2) == input*2
33-
assert pyzstd.decompress(z.encode(input)*2) == input*2
34+
assert z.decode(pyzstd.compress(input) * 2) == input * 2
35+
assert pyzstd.decompress(z.encode(input) * 2) == input * 2
36+
3437

3538
@pytest.mark.parametrize("input", test_data)
3639
def test_pyzstd_streaming(input):
3740
pyzstd_c = pyzstd.ZstdCompressor()
3841
pyzstd_d = pyzstd.ZstdDecompressor()
3942
z = Zstd()
40-
43+
4144
d_bytes = input
4245
pyzstd_c.compress(d_bytes)
4346
c_bytes = pyzstd_c.flush()
4447
assert z.decode(c_bytes) == d_bytes
4548
assert pyzstd_d.decompress(z.encode(d_bytes)) == d_bytes
4649

4750
# Test multiple streaming frames
48-
assert z.decode(c_bytes*2) == d_bytes*2
49-
assert z.decode(c_bytes*3) == d_bytes*3
50-
assert z.decode(c_bytes*99) == d_bytes*99
51+
assert z.decode(c_bytes * 2) == d_bytes * 2
52+
assert z.decode(c_bytes * 3) == d_bytes * 3
53+
assert z.decode(c_bytes * 99) == d_bytes * 99

numcodecs/tests/test_zstd.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ def test_streaming_decompression():
131131
with pytest.raises(RuntimeError, match='Zstd decompression error: invalid input data'):
132132
codec.decode(bytes4)
133133

134-
def generate_zstd_streaming_bytes(input: bytes, *, decompress: bool =False) -> bytes:
134+
135+
def generate_zstd_streaming_bytes(input: bytes, *, decompress: bool = False) -> bytes:
135136
"""
136137
Use the zstd command line interface to compress or decompress bytes in streaming mode.
137138
"""
@@ -140,23 +141,21 @@ def generate_zstd_streaming_bytes(input: bytes, *, decompress: bool =False) -> b
140141
else:
141142
args = []
142143

143-
p = subprocess.run(
144-
["zstd", "--no-check", *args],
145-
input=input,
146-
capture_output=True
147-
)
144+
p = subprocess.run(["zstd", "--no-check", *args], input=input, capture_output=True)
148145
return p.stdout
149146

147+
150148
def view_zstd_streaming_bytes():
151149
bytes_val = generate_zstd_streaming_bytes(b"Hello world!")
152150
print(f" bytes_val = {bytes_val}")
153151

154-
bytes3 = generate_zstd_streaming_bytes(b"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz" * 1024 * 32)
152+
bytes3 = generate_zstd_streaming_bytes(
153+
b"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz" * 1024 * 32
154+
)
155155
print(f" bytes3 = {bytes3}")
156156

157+
157158
def zstd_cli_available() -> bool:
158159
return not subprocess.run(
159-
["zstd", "-V"],
160-
stdout=subprocess.DEVNULL,
161-
stderr=subprocess.DEVNULL
160+
["zstd", "-V"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
162161
).returncode

0 commit comments

Comments
 (0)