Skip to content

Commit 68ad2a0

Browse files
DimitriPapadopoulosFrancescAlted
authored andcommitted
Reformat with the ruff formatter
ruff format .
1 parent 76bbc9c commit 68ad2a0

File tree

4 files changed

+50
-29
lines changed

4 files changed

+50
-29
lines changed

bench/compress_numpy.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939
np.copyto(out_, in_)
4040
tcpy = (time.time() - t0) / NREP
4141
print(
42-
" *** np.copyto() *** Time for memcpy():\t{:.3f} s\t({:.2f} GB/s)".format(
43-
tcpy, (N * 8 / tcpy) / 2**30
44-
)
42+
" *** np.copyto() *** Time for memcpy():\t{:.3f} s\t({:.2f} GB/s)".format(tcpy, (N * 8 / tcpy) / 2**30)
4543
)
4644

4745
print("\nTimes for compressing/decompressing:")

bench/pack_compress.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939
toc = time.time()
4040
tcpy = (toc - tic) / NREP
4141
print(
42-
" Time for copying array with np.copy: {:.3f} s ({:.2f} GB/s))"
43-
.format(tcpy, ((N * 8 / tcpy) / 2**30))
42+
" Time for copying array with np.copy: {:.3f} s ({:.2f} GB/s))".format(
43+
tcpy, ((N * 8 / tcpy) / 2**30)
44+
)
4445
)
4546

4647
if comprehensive_copy_timing:
@@ -51,8 +52,9 @@
5152
toc = time.time()
5253
tcpy = (toc - tic) / NREP
5354
print(
54-
" Time for copying array with np.copyto and empty_like: {:.3f} s ({:.2f} GB/s))"
55-
.format(tcpy, ((N * 8 / tcpy) / 2**30))
55+
" Time for copying array with np.copyto and empty_like: {:.3f} s ({:.2f} GB/s))".format(
56+
tcpy, ((N * 8 / tcpy) / 2**30)
57+
)
5658
)
5759

5860
# Unlike numpy.zeros, numpy.zeros_like doesn't use calloc, but instead uses
@@ -66,8 +68,9 @@
6668
toc = time.time()
6769
tcpy = (toc - tic) / NREP
6870
print(
69-
" Time for copying array with np.copyto and zeros: {:.3f} s ({:.2f} GB/s))"
70-
.format(tcpy, ((N * 8 / tcpy) / 2**30))
71+
" Time for copying array with np.copyto and zeros: {:.3f} s ({:.2f} GB/s))".format(
72+
tcpy, ((N * 8 / tcpy) / 2**30)
73+
)
7174
)
7275

7376
# Cause a page fault before the benchmark
@@ -78,8 +81,9 @@
7881
toc = time.time()
7982
tcpy = (toc - tic) / NREP
8083
print(
81-
" Time for copying array with np.copyto and full_like: {:.3f} s ({:.2f} GB/s))"
82-
.format(tcpy, ((N * 8 / tcpy) / 2**30))
84+
" Time for copying array with np.copyto and full_like: {:.3f} s ({:.2f} GB/s))".format(
85+
tcpy, ((N * 8 / tcpy) / 2**30)
86+
)
8387
)
8488

8589
tic = time.time()
@@ -89,8 +93,9 @@
8993
toc = time.time()
9094
tcpy = (toc - tic) / NREP
9195
print(
92-
" Time for copying array with numpy assignment: {:.3f} s ({:.2f} GB/s))"
93-
.format(tcpy, ((N * 8 / tcpy) / 2**30))
96+
" Time for copying array with numpy assignment: {:.3f} s ({:.2f} GB/s))".format(
97+
tcpy, ((N * 8 / tcpy) / 2**30)
98+
)
9499
)
95100

96101
print()
@@ -122,8 +127,9 @@
122127
tc = (ctoc - ctic) / NREP
123128
td = (dtoc - dtic) / NREP
124129
print(
125-
" Time for compress/decompress: {:.3f}/{:.3f} s ({:.2f}/{:.2f} GB/s)) "
126-
.format(tc, td, ((N * 8 / tc) / 2**30), ((N * 8 / td) / 2**30)),
130+
" Time for compress/decompress: {:.3f}/{:.3f} s ({:.2f}/{:.2f} GB/s)) ".format(
131+
tc, td, ((N * 8 / tc) / 2**30), ((N * 8 / td) / 2**30)
132+
),
127133
end="",
128134
)
129135
print("\tcr: {:5.1f}x".format(in_.size * in_.dtype.itemsize * 1.0 / len(c)))
@@ -141,8 +147,9 @@
141147
tc = (ctoc - ctic) / NREP
142148
td = (dtoc - dtic) / NREP
143149
print(
144-
" Time for pack_array2/unpack_array2: {:.3f}/{:.3f} s ({:.2f}/{:.2f} GB/s)) "
145-
.format(tc, td, ((N * 8 / tc) / 2**30), ((N * 8 / td) / 2**30)),
150+
" Time for pack_array2/unpack_array2: {:.3f}/{:.3f} s ({:.2f}/{:.2f} GB/s)) ".format(
151+
tc, td, ((N * 8 / tc) / 2**30), ((N * 8 / td) / 2**30)
152+
),
146153
end="",
147154
)
148155
print("\tcr: {:5.1f}x".format(in_.size * in_.dtype.itemsize * 1.0 / len(c)))
@@ -160,8 +167,9 @@
160167
tc = (ctoc - ctic) / NREP
161168
td = (dtoc - dtic) / NREP
162169
print(
163-
" Time for pack_tensor/unpack_tensor: {:.3f}/{:.3f} s ({:.2f}/{:.2f} GB/s)) "
164-
.format(tc, td, ((N * 8 / tc) / 2**30), ((N * 8 / td) / 2**30)),
170+
" Time for pack_tensor/unpack_tensor: {:.3f}/{:.3f} s ({:.2f}/{:.2f} GB/s)) ".format(
171+
tc, td, ((N * 8 / tc) / 2**30), ((N * 8 / td) / 2**30)
172+
),
165173
end="",
166174
)
167175
print("\tcr: {:5.1f}x".format(in_.size * in_.dtype.itemsize * 1.0 / len(c)))

bench/pack_tensor.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
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(
52+
tc, ((N * 8 / tc) / 2**30)
53+
),
5254
end="",
5355
)
5456
print("\tcr: {:5.1f}x".format(in_.size * in_.dtype.itemsize * 1.0 / len(c)))
@@ -65,7 +67,8 @@
6567
ctoc = time.time()
6668
tc = (ctoc - ctic) / NREP
6769
print(
68-
" Time for torch (torch.save):\t\t\t{:.3f} s ({:.2f} GB/s)) ".format(tc, ((N * 8 / tc) / 2**30)), end=""
70+
" Time for torch (torch.save):\t\t\t{:.3f} s ({:.2f} GB/s)) ".format(tc, ((N * 8 / tc) / 2**30)),
71+
end="",
6972
)
7073
buff.seek(0)
7174
c = buff.read()
@@ -85,7 +88,9 @@
8588
ctoc = time.time()
8689
tc = (ctoc - ctic) / NREP
8790
print(
88-
" Time for tensorflow (blosc2.pack_tensor):\t{:.3f} s ({:.2f} GB/s)) ".format(tc, ((N * 8 / tc) / 2**30)),
91+
" Time for tensorflow (blosc2.pack_tensor):\t{:.3f} s ({:.2f} GB/s)) ".format(
92+
tc, ((N * 8 / tc) / 2**30)
93+
),
8994
end="",
9095
)
9196
print("\tcr: {:5.1f}x".format(in_.size * in_.dtype.itemsize * 1.0 / len(c)))
@@ -101,7 +106,9 @@
101106
ctoc = time.time()
102107
tc = (ctoc - ctic) / NREP
103108
print(
104-
" Time for torch (blosc2.pack_tensor):\t\t{:.3f} s ({:.2f} GB/s)) ".format(tc, ((N * 8 / tc) / 2**30)),
109+
" Time for torch (blosc2.pack_tensor):\t\t{:.3f} s ({:.2f} GB/s)) ".format(
110+
tc, ((N * 8 / tc) / 2**30)
111+
),
105112
end="",
106113
)
107114
print("\tcr: {:5.1f}x".format(in_.size * in_.dtype.itemsize * 1.0 / len(c)))
@@ -120,7 +127,9 @@
120127
dtoc = time.time()
121128
td = (dtoc - dtic) / NREP
122129
print(
123-
" Time for tensorflow (tf.io.parse_tensor):\t{:.3f} s ({:.2f} GB/s)) ".format(td, ((N * 8 / td) / 2**30)),
130+
" Time for tensorflow (tf.io.parse_tensor):\t{:.3f} s ({:.2f} GB/s)) ".format(
131+
td, ((N * 8 / td) / 2**30)
132+
),
124133
)
125134

126135
with open("serialize_torch.bin", "rb") as f:
@@ -147,8 +156,9 @@
147156
dtoc = time.time()
148157
td = (dtoc - dtic) / NREP
149158
print(
150-
" Time for tensorflow (blosc2.unpack_tensor):\t{:.3f} s ({:.2f} GB/s)) "
151-
.format(td, ((N * 8 / td) / 2**30)),
159+
" Time for tensorflow (blosc2.unpack_tensor):\t{:.3f} s ({:.2f} GB/s)) ".format(
160+
td, ((N * 8 / td) / 2**30)
161+
),
152162
)
153163
assert np.array_equal(in_, out)
154164

@@ -164,6 +174,8 @@
164174

165175
td = (dtoc - dtic) / NREP
166176
print(
167-
" Time for torch (blosc2.unpack_tensor):\t{:.3f} s ({:.2f} GB/s)) ".format(td, ((N * 8 / td) / 2**30)),
177+
" Time for torch (blosc2.unpack_tensor):\t{:.3f} s ({:.2f} GB/s)) ".format(
178+
td, ((N * 8 / td) / 2**30)
179+
),
168180
)
169181
assert np.array_equal(in_, out)

tests/test_ufilters.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,17 @@ def backward2(input, output, meta, schunk):
9191

9292
blosc2.remove_urlpath(urlpath)
9393

94+
9495
@pytest.mark.parametrize(
9596
"cparams, dparams",
9697
[
9798
({"nthreads": 4, "filters": [255, blosc2.Filter.SHUFFLE], "filters_meta": [0, 0]}, {"nthreads": 1}),
98-
({"nthreads": 1, "filters": [255], "filters_meta": [4]}, {"nthreads": 4})
99+
({"nthreads": 1, "filters": [255], "filters_meta": [4]}, {"nthreads": 4}),
99100
],
100101
)
101102
def test_pyufilters_error(cparams, dparams):
102103
dtype = np.dtype(np.int32)
104+
103105
def forward(input, output, meta, schunk):
104106
nd_input = input.view(dtype)
105107
nd_output = output.view(dtype)
@@ -111,6 +113,7 @@ def backward(input, output, meta, schunk):
111113
nd_output = output.view(dtype)
112114

113115
nd_output[:] = nd_input - 1
116+
114117
if 255 not in blosc2.ufilters_registry:
115118
blosc2.register_filter(255, forward, backward)
116119

@@ -132,7 +135,7 @@ def backward(input, output, meta, schunk):
132135
"cparams, dparams",
133136
[
134137
({"nthreads": 4, "filters": [163, blosc2.Filter.SHUFFLE], "filters_meta": [0, 0]}, {"nthreads": 1}),
135-
({"nthreads": 1, "filters": [163], "filters_meta": [4]}, {"nthreads": 4})
138+
({"nthreads": 1, "filters": [163], "filters_meta": [4]}, {"nthreads": 4}),
136139
],
137140
)
138141
def test_dynamic_ufilters_error(cparams, dparams):

0 commit comments

Comments
 (0)