Skip to content

Commit

Permalink
Unnecessary comprehension (zarr-developers#1996)
Browse files Browse the repository at this point in the history
* Unnecessary comprehension

`all` can take a generator.

* Unnecessary comprehension

`tuple` can take a generator.
  • Loading branch information
DimitriPapadopoulos authored Jun 27, 2024
1 parent 50235c0 commit 61b9404
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/zarr/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ def __init__(self, selection: CoordinateSelection, shape: ChunkCoords, chunk_gri
# flatten selection
selection_broadcast = tuple(dim_sel.reshape(-1) for dim_sel in selection_broadcast)
chunks_multi_index_broadcast = tuple(
[dim_chunks.reshape(-1) for dim_chunks in chunks_multi_index_broadcast]
dim_chunks.reshape(-1) for dim_chunks in chunks_multi_index_broadcast
)

# ravel chunk indices
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def update_attributes(self, attributes: dict[str, JSON]) -> Self:
def parse_dimension_names(data: None | Iterable[str]) -> tuple[str, ...] | None:
if data is None:
return data
elif all([isinstance(x, str) for x in data]):
elif all(isinstance(x, str) for x in data):
return tuple(data)
else:
msg = f"Expected either None or a iterable of str, got {type(data)}"
Expand Down

0 comments on commit 61b9404

Please sign in to comment.