Skip to content

Commit e2aad24

Browse files
committed
optimize
1 parent 5e07bbb commit e2aad24

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

xarray/core/dataset.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ def _get_breaks_cached(
293293
# Determine the stop indices of the preferred chunks, but omit the last stop
294294
# (equal to the dim size). In particular, assume that when a sequence
295295
# expresses the preferred chunks, the sequence sums to the size.
296-
preferred_stops = set(
296+
preferred_stops = (
297297
range(preferred_chunk_sizes, size, preferred_chunk_sizes)
298298
if isinstance(preferred_chunk_sizes, int)
299-
else itertools.accumulate(preferred_chunk_sizes[:-1])
299+
else set(itertools.accumulate(preferred_chunk_sizes[:-1]))
300300
)
301301

302302
# Gather any stop indices of the specified chunks that are not a stop index
@@ -307,8 +307,7 @@ def _get_breaks_cached(
307307
actual_stops_2 = itertools.accumulate(chunk_sizes[:-1])
308308

309309
disagrees = itertools.compress(
310-
actual_stops_2,
311-
(a not in preferred_stops for a in actual_stops),
310+
actual_stops_2, (a not in preferred_stops for a in actual_stops)
312311
)
313312
try:
314313
return next(disagrees)

0 commit comments

Comments
 (0)