diff --git a/ome_zarr/axes.py b/ome_zarr/axes.py index 68ba2351..2de7d04a 100644 --- a/ome_zarr/axes.py +++ b/ome_zarr/axes.py @@ -71,7 +71,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: @@ -93,7 +93,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 @@ -106,7 +106,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 d1877d85..8be42dd1 100644 --- a/ome_zarr/format.py +++ b/ome_zarr/format.py @@ -290,14 +290,13 @@ 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 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 +307,11 @@ 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 number of image dimensions: {ndim}" ) for value in scale: if not isinstance(value, (float, int)): @@ -329,12 +327,11 @@ 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 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 ccfe0394..6fa8a97a 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: Optional[list[Optional[Any]]] = [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 deac331c..c32d277c 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 db811b4c..d3982df1 100644 --- a/ome_zarr/writer.py +++ b/ome_zarr/writer.py @@ -918,8 +918,7 @@ def _create_mip( if scaler is not None: 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"Can't downsample if size of x or y dimension is 1. Shape: {image.shape}" ) mip = scaler.func(image) else: