diff --git a/ome_zarr/csv.py b/ome_zarr/csv.py index 01601ea7..6cea603d 100644 --- a/ome_zarr/csv.py +++ b/ome_zarr/csv.py @@ -19,7 +19,7 @@ def parse_csv_value(value: str, col_type: str) -> str | float | int | bool: if col_type == "d": rv = float(value) elif col_type == "l": - rv = int(round(float(value))) + rv = round(float(value)) elif col_type == "b": rv = bool(value) except ValueError: diff --git a/ome_zarr/io.py b/ome_zarr/io.py index b49f50a0..3a4d2fd2 100644 --- a/ome_zarr/io.py +++ b/ome_zarr/io.py @@ -134,7 +134,7 @@ def basename(self) -> str: >>> ZarrLocation("https://example.com/baz/").basename() 'baz' """ - path = self.__path.endswith("/") and self.__path[0:-1] or self.__path + path = (self.__path.endswith("/") and self.__path[0:-1]) or self.__path return path.split("/")[-1] # TODO: update to from __future__ import annotations with 3.7+ diff --git a/ome_zarr/writer.py b/ome_zarr/writer.py index e327e463..78631fa3 100644 --- a/ome_zarr/writer.py +++ b/ome_zarr/writer.py @@ -28,7 +28,7 @@ def _get_valid_axes( ndim: int | None = None, axes: str | list[str] | list[dict[str, str]] | None = None, fmt: Format = CurrentFormat(), -) -> None | list[str] | list[dict[str, str]]: +) -> list[str] | list[dict[str, str]] | None: """Returns list of axes valid for fmt.version or raise exception if invalid""" if fmt.version in ("0.1", "0.2"): diff --git a/tests/test_reader.py b/tests/test_reader.py index 67d69f4f..86188a0e 100644 --- a/tests/test_reader.py +++ b/tests/test_reader.py @@ -36,7 +36,7 @@ def test_label(self): def test_omero(self): reader = Reader(parse_url(str(self.path)))() - image_node = list(reader)[0] + image_node = next(iter(reader)) omero = image_node.zarr.root_attrs.get("omero") assert "channels" in omero assert isinstance(omero["channels"], list) diff --git a/tests/test_upgrade.py b/tests/test_upgrade.py index cda9bfb7..7c01476d 100644 --- a/tests/test_upgrade.py +++ b/tests/test_upgrade.py @@ -29,7 +29,7 @@ def assert_data(self, path, shape, fmt, mode="r"): loc = parse_url(path, mode=mode, fmt=fmt) assert loc reader = Reader(loc) - node = list(reader())[0] + node = next(iter(reader())) assert Multiscales.matches(node.zarr) assert node.data[0].shape == shape assert np.max(node.data[0]) > 0 diff --git a/tests/test_writer.py b/tests/test_writer.py index 753963ea..a396ca6e 100644 --- a/tests/test_writer.py +++ b/tests/test_writer.py @@ -108,7 +108,7 @@ def test_writer( # Verify reader = Reader(parse_url(f"{self.path}/test")) - node = list(reader())[0] + node = next(iter(reader())) assert Multiscales.matches(node.zarr) if version.version in ("0.1", "0.2"): # v0.1 and v0.2 MUST be 5D @@ -136,7 +136,7 @@ def test_write_image_current(self, array_constructor): data = array_constructor(data) write_image(data, self.group, axes="zyx") reader = Reader(parse_url(f"{self.path}/test")) - image_node = list(reader())[0] + image_node = next(iter(reader())) for transfs in image_node.metadata["coordinateTransformations"]: assert len(transfs) == 1 assert transfs[0]["type"] == "scale" @@ -186,7 +186,7 @@ def test_write_image_dask(self, read_from_zarr, compute): dask_delayed_jobs = persist(*dask_delayed_jobs) reader = Reader(parse_url(f"{self.path}/test")) - image_node = list(reader())[0] + image_node = next(iter(reader())) first_chunk = [c[0] for c in image_node.data[0].chunks] assert tuple(first_chunk) == _retuple(chunks, image_node.data[0].shape) for level, transfs in enumerate( @@ -1069,7 +1069,7 @@ def scaler(self, request): def verify_label_data(self, label_name, label_data, fmt, shape, transformations): # Verify image data reader = Reader(parse_url(f"{self.path}/labels/{label_name}")) - node = list(reader())[0] + node = next(iter(reader())) assert Multiscales.matches(node.zarr) if fmt.version in ("0.1", "0.2"): # v0.1 and v0.2 MUST be 5D