diff --git a/ome_zarr/axes.py b/ome_zarr/axes.py index edfd07f0..ac55d896 100644 --- a/ome_zarr/axes.py +++ b/ome_zarr/axes.py @@ -69,7 +69,7 @@ def _validate_axes_types(self) -> None: unknown_types = [atype for atype in axes_types if atype not in known_types] if len(unknown_types) > 1: raise ValueError( - "Too many unknown axes types. 1 allowed, found: %s" % unknown_types + f"Too many unknown axes types. 1 allowed, found: {unknown_types}" ) def _last_index(item: str, item_list: list[Any]) -> int: @@ -91,7 +91,7 @@ def _get_names(self) -> list[str]: axes_names = [] for axis in self.axes: if "name" not in axis: - raise ValueError("Axis Dict %s has no 'name'" % axis) + raise ValueError(f"Axis Dict {axis} has no 'name'") axes_names.append(axis["name"]) return axes_names @@ -104,7 +104,7 @@ def _validate_03(self) -> None: if val_axes not in [("z", "y", "x"), ("c", "y", "x"), ("t", "y", "x")]: raise ValueError( "3D data must have axes ('z', 'y', 'x') or ('c', 'y', 'x')" - " or ('t', 'y', 'x'), not %s" % (val_axes,) + f" or ('t', 'y', 'x'), not {val_axes}" ) elif len(val_axes) == 4: if val_axes not in [ diff --git a/ome_zarr/format.py b/ome_zarr/format.py index 085f7602..e0fba096 100644 --- a/ome_zarr/format.py +++ b/ome_zarr/format.py @@ -290,14 +290,14 @@ def validate_coordinate_transformations( ct_count = len(coordinate_transformations) if ct_count != nlevels: raise ValueError( - "coordinate_transformations count: %s must match datasets %s" - % (ct_count, nlevels) + f"coordinate_transformations count: {ct_count} must match " + f"datasets {nlevels}" ) for transformations in coordinate_transformations: assert isinstance(transformations, list) types = [t.get("type", None) for t in transformations] if any(t is None for t in types): - raise ValueError("Missing type in: %s" % transformations) + raise ValueError(f"Missing type in: {transformations}") # validate scales... if sum(t == "scale" for t in types) != 1: raise ValueError( @@ -308,12 +308,12 @@ def validate_coordinate_transformations( raise ValueError("First coordinate_transformations must be 'scale'") first = transformations[0] if "scale" not in transformations[0]: - raise ValueError("Missing scale argument in: %s" % first) + raise ValueError(f"Missing scale argument in: {first}") scale = first["scale"] if len(scale) != ndim: raise ValueError( - "'scale' list %s must match number of image dimensions: %s" - % (scale, ndim) + f"'scale' list {scale} must match " + f"number of image dimensions: {ndim}" ) for value in scale: if not isinstance(value, (float, int)): @@ -329,12 +329,12 @@ def validate_coordinate_transformations( elif sum(translation_types) == 1: transformation = transformations[types.index("translation")] if "translation" not in transformation: - raise ValueError("Missing scale argument in: %s" % first) + raise ValueError(f"Missing scale argument in: {first}") translation = transformation["translation"] if len(translation) != ndim: raise ValueError( - "'translation' list %s must match image dimensions count: %s" - % (translation, ndim) + f"'translation' list {translation} must match " + f"image dimensions count: {ndim}" ) for value in translation: if not isinstance(value, (float, int)): diff --git a/ome_zarr/reader.py b/ome_zarr/reader.py index f01e066d..628b0549 100644 --- a/ome_zarr/reader.py +++ b/ome_zarr/reader.py @@ -301,7 +301,7 @@ def __init__(self, node: Node) -> None: for resolution in self.datasets: data: da.core.Array = self.array(resolution, version) chunk_sizes = [ - str(c[0]) + (" (+ %s)" % c[-1] if c[-1] != c[0] else "") + str(c[0]) + (f" (+ {c[-1]})" if c[-1] != c[0] else "") for c in data.chunks ] LOGGER.info("resolution: %s", resolution) @@ -353,7 +353,7 @@ def __init__(self, node: Node) -> None: colormaps = [] contrast_limits: list[Any | None] | None = [None for x in channels] - names: list[str] = [("channel_%d" % idx) for idx, ch in enumerate(channels)] + names: list[str] = [f"channel_{idx}" for idx, ch in enumerate(channels)] visibles: list[bool] = [True for x in channels] for idx, ch in enumerate(channels): diff --git a/ome_zarr/scale.py b/ome_zarr/scale.py index def80888..0f39750b 100644 --- a/ome_zarr/scale.py +++ b/ome_zarr/scale.py @@ -147,7 +147,7 @@ def __create_group( if i == 0: path = "base" else: - path = "%s" % i + path = str(i) grp.create_dataset(path, data=pyramid[i]) series.append({"path": path}) return grp diff --git a/ome_zarr/writer.py b/ome_zarr/writer.py index e327e463..87cef0db 100644 --- a/ome_zarr/writer.py +++ b/ome_zarr/writer.py @@ -919,7 +919,7 @@ def _create_mip( if image.shape[-1] == 1 or image.shape[-2] == 1: raise ValueError( "Can't downsample if size of x or y dimension is 1. " - "Shape: %s" % (image.shape,) + f"Shape: {image.shape}" ) mip = scaler.func(image) else: