Skip to content

Commit 15c8d1f

Browse files
authored
Merge pull request #426 from DimitriPapadopoulos/UP
Apply ruff/pyupgrade rules (UP)
2 parents 84ba4f1 + 47b37a7 commit 15c8d1f

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

ome_zarr/axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _validate_axes_types(self) -> None:
6969
unknown_types = [atype for atype in axes_types if atype not in known_types]
7070
if len(unknown_types) > 1:
7171
raise ValueError(
72-
"Too many unknown axes types. 1 allowed, found: %s" % unknown_types
72+
f"Too many unknown axes types. 1 allowed, found: {unknown_types}"
7373
)
7474

7575
def _last_index(item: str, item_list: list[Any]) -> int:
@@ -91,7 +91,7 @@ def _get_names(self) -> list[str]:
9191
axes_names = []
9292
for axis in self.axes:
9393
if "name" not in axis:
94-
raise ValueError("Axis Dict %s has no 'name'" % axis)
94+
raise ValueError(f"Axis Dict {axis} has no 'name'")
9595
axes_names.append(axis["name"])
9696
return axes_names
9797

@@ -104,7 +104,7 @@ def _validate_03(self) -> None:
104104
if val_axes not in [("z", "y", "x"), ("c", "y", "x"), ("t", "y", "x")]:
105105
raise ValueError(
106106
"3D data must have axes ('z', 'y', 'x') or ('c', 'y', 'x')"
107-
" or ('t', 'y', 'x'), not %s" % (val_axes,)
107+
f" or ('t', 'y', 'x'), not {val_axes}"
108108
)
109109
elif len(val_axes) == 4:
110110
if val_axes not in [

ome_zarr/format.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,14 @@ def validate_coordinate_transformations(
290290
ct_count = len(coordinate_transformations)
291291
if ct_count != nlevels:
292292
raise ValueError(
293-
"coordinate_transformations count: %s must match datasets %s"
294-
% (ct_count, nlevels)
293+
f"coordinate_transformations count: {ct_count} must match "
294+
f"datasets {nlevels}"
295295
)
296296
for transformations in coordinate_transformations:
297297
assert isinstance(transformations, list)
298298
types = [t.get("type", None) for t in transformations]
299299
if any(t is None for t in types):
300-
raise ValueError("Missing type in: %s" % transformations)
300+
raise ValueError(f"Missing type in: {transformations}")
301301
# validate scales...
302302
if sum(t == "scale" for t in types) != 1:
303303
raise ValueError(
@@ -308,12 +308,12 @@ def validate_coordinate_transformations(
308308
raise ValueError("First coordinate_transformations must be 'scale'")
309309
first = transformations[0]
310310
if "scale" not in transformations[0]:
311-
raise ValueError("Missing scale argument in: %s" % first)
311+
raise ValueError(f"Missing scale argument in: {first}")
312312
scale = first["scale"]
313313
if len(scale) != ndim:
314314
raise ValueError(
315-
"'scale' list %s must match number of image dimensions: %s"
316-
% (scale, ndim)
315+
f"'scale' list {scale} must match "
316+
f"number of image dimensions: {ndim}"
317317
)
318318
for value in scale:
319319
if not isinstance(value, (float, int)):
@@ -329,12 +329,12 @@ def validate_coordinate_transformations(
329329
elif sum(translation_types) == 1:
330330
transformation = transformations[types.index("translation")]
331331
if "translation" not in transformation:
332-
raise ValueError("Missing scale argument in: %s" % first)
332+
raise ValueError(f"Missing scale argument in: {first}")
333333
translation = transformation["translation"]
334334
if len(translation) != ndim:
335335
raise ValueError(
336-
"'translation' list %s must match image dimensions count: %s"
337-
% (translation, ndim)
336+
f"'translation' list {translation} must match "
337+
f"image dimensions count: {ndim}"
338338
)
339339
for value in translation:
340340
if not isinstance(value, (float, int)):

ome_zarr/reader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def __init__(self, node: Node) -> None:
301301
for resolution in self.datasets:
302302
data: da.core.Array = self.array(resolution, version)
303303
chunk_sizes = [
304-
str(c[0]) + (" (+ %s)" % c[-1] if c[-1] != c[0] else "")
304+
str(c[0]) + (f" (+ {c[-1]})" if c[-1] != c[0] else "")
305305
for c in data.chunks
306306
]
307307
LOGGER.info("resolution: %s", resolution)
@@ -353,7 +353,7 @@ def __init__(self, node: Node) -> None:
353353

354354
colormaps = []
355355
contrast_limits: list[Any | None] | None = [None for x in channels]
356-
names: list[str] = [("channel_%d" % idx) for idx, ch in enumerate(channels)]
356+
names: list[str] = [f"channel_{idx}" for idx, ch in enumerate(channels)]
357357
visibles: list[bool] = [True for x in channels]
358358

359359
for idx, ch in enumerate(channels):

ome_zarr/scale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def __create_group(
147147
if i == 0:
148148
path = "base"
149149
else:
150-
path = "%s" % i
150+
path = str(i)
151151
grp.create_dataset(path, data=pyramid[i])
152152
series.append({"path": path})
153153
return grp

ome_zarr/writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ def _create_mip(
919919
if image.shape[-1] == 1 or image.shape[-2] == 1:
920920
raise ValueError(
921921
"Can't downsample if size of x or y dimension is 1. "
922-
"Shape: %s" % (image.shape,)
922+
f"Shape: {image.shape}"
923923
)
924924
mip = scaler.func(image)
925925
else:

0 commit comments

Comments
 (0)