Skip to content

Commit

Permalink
reduce mask checks
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Jun 16, 2023
1 parent 2821a3f commit 501613e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions seaduck/smart_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ def smart_read(da, indexes_tuple, dask_more_efficient=100, chunks="auto"):
)

shifted_indexes = []
mask = True
mask = None
for block_id, indexes, chunks in zip(block_ids, indexes_tuple, data.chunks):
shifted = indexes - sum(chunks[:block_id])
block_mask = (shifted >= 0) & (shifted < chunks[block_id])
if not block_mask.any() or not (mask := mask & block_mask).any():
if not (mask := block_mask if mask is None else mask & block_mask).any():
break # empty block
shifted_indexes.append(shifted)
else:
Expand Down

0 comments on commit 501613e

Please sign in to comment.