Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply some ruff/Perflint rules (PERF) #432

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading