Skip to content

Commit 9343ee0

Browse files
Apply ruff/pyupgrade rule
UP031 Use format specifiers instead of percent format
1 parent 1740dd3 commit 9343ee0

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

bench/ndarray/compute_expr_numba.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ def udf_numba(inputs, output, offset):
9999
npexpr = expr.replace("sin", "np.sin").replace("cos", "np.cos")
100100
t0 = time()
101101
npres = eval(npexpr, vardict)
102-
print("NumPy took %.3f s" % (time() - t0))
102+
print(f"NumPy took {time() - t0:.3f} s")
103103
# ne.set_num_threads(1)
104104
# nb.set_num_threads(1) # this does not work that well; better use the NUMBA_NUM_THREADS env var
105105
t0 = time()
106106
ne.evaluate(expr, vardict, out=np.empty_like(npx))
107-
print("NumExpr took %.3f s" % (time() - t0))
107+
print(f"NumExpr took {time() - t0:.3f} s")
108108

109109
# Compute the expression with Blosc2
110110
blosc2.cparams_dflts["codec"] = blosc2.Codec.LZ4
@@ -113,19 +113,19 @@ def udf_numba(inputs, output, offset):
113113
c = eval(b2expr, b2vardict)
114114
t0 = time()
115115
d = c.compute()
116-
print("LazyExpr+compute took %.3f s" % (time() - t0))
116+
print(f"LazyExpr+compute took {time() - t0:.3f} s")
117117
# Check
118118
np.testing.assert_allclose(d[:], npres, rtol=rtol, atol=atol)
119119
t0 = time()
120120
d = c[:]
121-
print("LazyExpr+getitem took %.3f s" % (time() - t0))
121+
print(f"LazyExpr+getitem took {time() - t0:.3f} s")
122122
# Check
123123
np.testing.assert_allclose(d[:], npres, rtol=rtol, atol=atol)
124124

125125
# nb.set_num_threads(1)
126126
t0 = time()
127127
res = func_numba(npx, npy, npz, n)
128-
print("Numba took %.3f s" % (time() - t0))
128+
print(f"Numba took {time() - t0:.3f} s")
129129
np.testing.assert_allclose(res, npres, rtol=rtol, atol=atol)
130130

131131
inputs = (x,)
@@ -139,9 +139,9 @@ def udf_numba(inputs, output, offset):
139139
# getitem but using chunked evaluation
140140
t0 = time()
141141
res = expr_.compute()
142-
print("LazyUDF+compute took %.3f s" % (time() - t0))
142+
print(f"LazyUDF+compute took {time() - t0:.3f} s")
143143
np.testing.assert_allclose(res[...], npres, rtol=rtol, atol=atol)
144144
t0 = time()
145145
res = expr_[:]
146-
print("LazyUDF+getitem took %.3f s" % (time() - t0))
146+
print(f"LazyUDF+getitem took {time() - t0:.3f} s")
147147
np.testing.assert_allclose(res[...], npres, rtol=rtol, atol=atol)

bench/ndarray/reduce_expr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
t0 = time()
5555
npres = eval(npexpr, vardict).sum(axis=axis)
5656
tref = time() - t0
57-
print("NumPy took %.3f s" % tref)
57+
print(f"NumPy took {tref:.3f} s")
5858
# ne.set_num_threads(1)
5959
# nb.set_num_threads(1) # this does not work that well; better use the NUMBA_NUM_THREADS env var
6060
t0 = time()

0 commit comments

Comments
 (0)