Skip to content

Commit 8b348c1

Browse files
Use ruff-format instead of black, bump ruff version (#963)
Issue: rapidsai/build-planning#130 Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) Approvers: - Gregory Lee (https://github.com/grlee77) - https://github.com/jakirkham URL: #963
1 parent 41a40d3 commit 8b348c1

File tree

93 files changed

+679
-611
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+679
-611
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,13 @@ repos:
1313
- id: trailing-whitespace
1414
- id: end-of-file-fixer
1515
- id: debug-statements
16-
- repo: https://github.com/psf/black
17-
rev: 23.10.1
18-
hooks:
19-
- id: black
20-
args: ["--config", "python/cucim/pyproject.toml"]
2116
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: v0.6.1
17+
rev: v0.14.3
2318
hooks:
24-
- id: ruff
19+
- id: ruff-check
2520
types_or: [python, pyi]
2621
args: [--fix, --exit-non-zero-on-fix, --config, "python/cucim/pyproject.toml"]
22+
- id: ruff-format
2723
- repo: https://github.com/codespell-project/codespell
2824
rev: v2.2.6
2925
hooks:

benchmarks/skimage/_image_bench.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,20 +202,14 @@ def run_benchmark(self, duration=3, verbose=True):
202202
props = cp.cuda.runtime.getDeviceProperties(device.id)
203203
gpu_name = props["name"].decode()
204204

205-
df.at[index, "GPU: DEV Name"] = [
206-
gpu_name for i in range(len(df))
207-
]
205+
df.at[index, "GPU: DEV Name"] = [gpu_name for i in range(len(df))]
208206
cmd = "cat /proc/cpuinfo"
209207
cpuinfo = subprocess.check_output(cmd, shell=True).strip()
210208
cpu_name = (
211-
re.search("\nmodel name.*\n", cpuinfo.decode())
212-
.group(0)
213-
.strip("\n")
209+
re.search("\nmodel name.*\n", cpuinfo.decode()).group(0).strip("\n")
214210
)
215211
cpu_name = cpu_name.replace("model name\t: ", "")
216-
df.at[index, "CPU: DEV Name"] = [
217-
cpu_name for i in range(len(df))
218-
]
212+
df.at[index, "CPU: DEV Name"] = [cpu_name for i in range(len(df))]
219213

220214
# accelerations[arr_index] = df.at[index, "GPU accel"]
221215
if verbose:

benchmarks/skimage/bench_convolve.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55
Benchmark locally modified ndimage functions vs. their CuPy counterparts
66
"""
7+
78
import cupy as cp
89
import cupyx.scipy.ndimage as ndi
910
from cupyx.profiler import benchmark

benchmarks/skimage/cucim_color_bench.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ class ColorBench(ImageBench):
4141
def set_args(self, dtype):
4242
if self.shape[-1] != 3:
4343
raise ValueError("shape must be 3 on the last axis")
44-
imaged = cupy.testing.shaped_random(
45-
self.shape, xp=cp, dtype=dtype, scale=1.0
46-
)
44+
imaged = cupy.testing.shaped_random(self.shape, xp=cp, dtype=dtype, scale=1.0)
4745
image = cp.asnumpy(imaged)
4846
self.args_cpu = (image,)
4947
self.args_gpu = (imaged,)
@@ -79,9 +77,7 @@ class RGBABench(ImageBench):
7977
def set_args(self, dtype):
8078
if self.shape[-1] != 4:
8179
raise ValueError("shape must be 4 on the last axis")
82-
imaged = cupy.testing.shaped_random(
83-
self.shape, xp=cp, dtype=dtype, scale=1.0
84-
)
80+
imaged = cupy.testing.shaped_random(self.shape, xp=cp, dtype=dtype, scale=1.0)
8581
image = cp.asnumpy(imaged)
8682
self.args_cpu = (image,)
8783
self.args_gpu = (imaged,)
@@ -116,9 +112,7 @@ def __init__(
116112

117113
def _generate_labels(self, dtype):
118114
ndim = len(self.shape)
119-
blobs_kwargs = dict(
120-
blob_size_fraction=0.05, volume_fraction=0.35, rng=5
121-
)
115+
blobs_kwargs = dict(blob_size_fraction=0.05, volume_fraction=0.35, rng=5)
122116
# binary blobs only creates square outputs
123117
labels = measure.label(
124118
data.binary_blobs(max(self.shape), n_dim=ndim, **blobs_kwargs)
@@ -314,8 +308,7 @@ def main(args):
314308
"--img_size",
315309
type=str,
316310
help=(
317-
"Size of input image (omit color channel, it will be appended "
318-
"as needed)"
311+
"Size of input image (omit color channel, it will be appended as needed)"
319312
),
320313
required=True,
321314
)

benchmarks/skimage/cucim_exposure_bench.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ def set_args(self, dtype):
2323
scale = 256
2424
else:
2525
scale = 1.0
26-
imaged = cupy.testing.shaped_random(
27-
self.shape, xp=cp, dtype=dtype, scale=scale
28-
)
26+
imaged = cupy.testing.shaped_random(self.shape, xp=cp, dtype=dtype, scale=scale)
2927
image = cp.asnumpy(imaged)
3028
self.args_cpu = (image,)
3129
self.args_gpu = (imaged,)
@@ -37,9 +35,7 @@ def set_args(self, dtype):
3735
scale = 256
3836
else:
3937
scale = 1.0
40-
imaged = cupy.testing.shaped_random(
41-
self.shape, xp=cp, dtype=dtype, scale=scale
42-
)
38+
imaged = cupy.testing.shaped_random(self.shape, xp=cp, dtype=dtype, scale=scale)
4339
imaged2 = cupy.testing.shaped_random(
4440
self.shape, xp=cp, dtype=dtype, scale=scale
4541
)

benchmarks/skimage/cucim_feature_bench.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ def set_args(self, dtype):
4040
offsets = rng.integers(0, np.prod(img.shape), num_ellipse)
4141
locs = np.unravel_index(offsets, img.shape)
4242
for loc in zip(*locs):
43-
loc = tuple(
44-
min(p, s - es) for p, s, es in zip(loc, img.shape, e.shape)
45-
)
43+
loc = tuple(min(p, s - es) for p, s, es in zip(loc, img.shape, e.shape))
4644
sl = tuple(slice(p, p + es) for p, es in zip(loc, e.shape))
4745
img[sl] = e
4846
else:

benchmarks/skimage/cucim_filters_bench.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@ def main(args):
162162

163163
if function_name == "gabor" and np.prod(shape) > 1000000:
164164
# avoid cases that are too slow on the CPU
165-
var_kwargs["frequency"] = [
166-
f for f in var_kwargs["frequency"] if f >= 0.1
167-
]
165+
var_kwargs["frequency"] = [f for f in var_kwargs["frequency"] if f >= 0.1]
168166

169167
if function_name == "median":
170168
footprints = []

benchmarks/skimage/cucim_measure_bench.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,7 @@ def main(args):
236236
continue
237237

238238
if function_name in ["label", "regionprops"]:
239-
Tester = (
240-
LabelBench if function_name == "label" else RegionpropsBench
241-
)
239+
Tester = LabelBench if function_name == "label" else RegionpropsBench
242240

243241
for contiguous_labels in [True, False]:
244242
if contiguous_labels:
@@ -293,9 +291,7 @@ def main(args):
293291
if function_name == "block_reduce":
294292
ndim = len(shape)
295293
if shape[-1] == 3:
296-
block_sizes = [
297-
(b,) * (ndim - 1) + (3,) for b in (16, 32, 64)
298-
]
294+
block_sizes = [(b,) * (ndim - 1) + (3,) for b in (16, 32, 64)]
299295
else:
300296
block_sizes = [(b,) * ndim for b in (16, 32, 64)]
301297
var_kwargs["block_size"] = block_sizes
@@ -308,9 +304,7 @@ def main(args):
308304
ndim = len(shape)
309305
footprint_sizes = [3, 5, 7, 9] if ndim == 2 else [3, 5, 7]
310306
for footprint_size in [3, 5, 7, 9]:
311-
footprints.append(
312-
np.ones((footprint_sizes,) * ndim, dtype=bool)
313-
)
307+
footprints.append(np.ones((footprint_sizes,) * ndim, dtype=bool))
314308
var_kwargs["footprint"] = footprints
315309

316310
if function_name in ["gaussian", "unsharp_mask"]:
@@ -337,9 +331,7 @@ def main(args):
337331

338332

339333
if __name__ == "__main__":
340-
parser = argparse.ArgumentParser(
341-
description="Benchmarking cuCIM measure functions"
342-
)
334+
parser = argparse.ArgumentParser(description="Benchmarking cuCIM measure functions")
343335
func_name_choices = [
344336
"label",
345337
"regionprops",

benchmarks/skimage/cucim_metrics_bench.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ def __init__(
5656

5757
def _generate_labels(self, dtype, rng=5):
5858
ndim = len(self.shape)
59-
blobs_kwargs = dict(
60-
blob_size_fraction=0.05, volume_fraction=0.35, rng=rng
61-
)
59+
blobs_kwargs = dict(blob_size_fraction=0.05, volume_fraction=0.35, rng=rng)
6260
# binary blobs only creates square outputs
6361
labels = measure.label(
6462
data.binary_blobs(max(self.shape), n_dim=ndim, **blobs_kwargs)
@@ -171,9 +169,7 @@ def main(args):
171169
run_cpu=run_cpu,
172170
)
173171
else:
174-
raise ValueError(
175-
f"benchmark function not configured for {function_name}"
176-
)
172+
raise ValueError(f"benchmark function not configured for {function_name}")
177173
results = B.run_benchmark(duration=args.duration)
178174
all_results = pd.concat([all_results, results["full"]])
179175

@@ -185,9 +181,7 @@ def main(args):
185181

186182

187183
if __name__ == "__main__":
188-
parser = argparse.ArgumentParser(
189-
description="Benchmarking cuCIM metrics functions"
190-
)
184+
parser = argparse.ArgumentParser(description="Benchmarking cuCIM metrics functions")
191185
func_name_choices = [
192186
"structural_similarity",
193187
"mean_squared_error",

benchmarks/skimage/cucim_morphology_bench.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,7 @@ def main(args):
322322
"--img_size",
323323
type=str,
324324
help=(
325-
"Size of input image (omit color channel, it will be appended "
326-
"as needed)"
325+
"Size of input image (omit color channel, it will be appended as needed)"
327326
),
328327
required=True,
329328
)

0 commit comments

Comments
 (0)