Skip to content

Commit

Permalink
Apply ruff/Perflint rule PERF401
Browse files Browse the repository at this point in the history
PERF401 Use a list comprehension to create a transformed list
  • Loading branch information
DimitriPapadopoulos committed Jan 25, 2025
1 parent 14f407f commit 347c197
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
11 changes: 5 additions & 6 deletions ome_zarr/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,15 @@ def dict_to_zarr(
if plate_attrs is None and not multiscales:
raise Exception("zarr_path must be to plate.zarr or image.zarr")

labels_paths = []
if plate_attrs is not None:
# look for 'label/0' under the first field of each Well
field = "0"
for w in plate_attrs.get("wells", []):
labels_paths.append(
os.path.join(zarr_path, w["path"], field, "labels", "0")
)
labels_paths = [
os.path.join(zarr_path, w["path"], field, "labels", "0")
for w in plate_attrs.get("wells", [])
]
else:
labels_paths.append(os.path.join(zarr_path, "labels", "0"))
labels_paths = [os.path.join(zarr_path, "labels", "0")]

for path_to_labels in labels_paths:
label_group = zarr_open(path_to_labels)
Expand Down
6 changes: 3 additions & 3 deletions ome_zarr/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,9 @@ def get_tile(row: int, col: int) -> da.core.Array:
lazy_rows = []
# For level 0, return whole image for each tile
for row in range(self.row_count):
lazy_row: list[da.Array] = []
for col in range(self.column_count):
lazy_row.append(get_tile(row, col))
lazy_row: list[da.Array] = [
get_tile(row, col) for col in range(self.column_count)
]
lazy_rows.append(da.concatenate(lazy_row, axis=len(self.axes) - 1))
return da.concatenate(lazy_rows, axis=len(self.axes) - 2)

Expand Down
4 changes: 1 addition & 3 deletions tests/test_starting_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ def initdir(self, tmpdir):
create_zarr(str(self.path))

def matches(self, node: Node, expected: list[type[Spec]]):
found: list[type[Spec]] = list()
for spec in node.specs:
found.append(type(spec))
found: list[type[Spec]] = [type(spec) for spec in node.specs]

expected_names = sorted(x.__name__ for x in expected)
found_names = sorted(x.__name__ for x in found)
Expand Down

0 comments on commit 347c197

Please sign in to comment.