Skip to content

Commit

Permalink
Don't re-iterate generator expression
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbb committed Oct 30, 2024
1 parent d5c9c88 commit dd64290
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mesmerize_core/algorithms/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ def make_projection_parallel(Yr: np.ndarray, dims: tuple[int, ...], T: int,
p_img_flat = np.empty(n_pix, dtype=Yr.dtype)
chunk_size = estimate_n_pixels_per_process(get_n_processes(dview), T, dims)
chunk_starts = range(0, n_pix, chunk_size)
chunk_slices = (slice(start, min(start + chunk_size, n_pix)) for start in chunk_starts)
chunks = (Yr[sl] for sl in chunk_slices)
args = ([ch, proj_type] for ch in chunks)
chunk_slices = [slice(start, min(start + chunk_size, n_pix)) for start in chunk_starts]
args = ((Yr[chunk_slice], proj_type) for chunk_slice in chunk_slices)
for chunk_slice, chunk_proj in zip(chunk_slices, dview.imap(make_chunk_projection_helper, args)):
p_img_flat[chunk_slice] = chunk_proj

Expand Down

0 comments on commit dd64290

Please sign in to comment.