Skip to content

Commit 1933e0b

Browse files
committed
Small cleanup
1 parent 21b0949 commit 1933e0b

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

xarray/core/parallel.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,6 @@ def subset_dataset_to_block(
491491
for dim in variable.dims
492492
}
493493
if set(variable.dims) < chunk_dims_set:
494-
# We are including a dimension coordinate,
495-
# minimize duplication by not copying it in the graph for every chunk.
496494
this_var_chunk_tuple = tuple(
497495
chunk_index[dim] for dim in variable.dims
498496
)
@@ -502,6 +500,8 @@ def subset_dataset_to_block(
502500
chunk_variable_task = (
503501
f"{name}-{gname}-{dask.base.tokenize(subsetter)}",
504502
) + this_var_chunk_tuple
503+
# We are including a dimension coordinate,
504+
# minimize duplication by not copying it in the graph for every chunk.
505505
if variable.ndim == 0 or chunk_variable_task not in graph:
506506
subset = variable.isel(subsetter)
507507
graph[chunk_variable_task] = (
@@ -539,7 +539,6 @@ def subset_dataset_to_block(
539539
}
540540
expected["data_vars"] = set(template.data_vars.keys()) # type: ignore[assignment]
541541
expected["coords"] = set(template.coords.keys()) # type: ignore[assignment]
542-
543542
# Minimize duplication due to broadcasting by only including any new or modified indexes
544543
# Others can be inferred by inputs to wrapper (GH8412)
545544
expected["indexes"] = {
@@ -560,14 +559,11 @@ def subset_dataset_to_block(
560559
gname_l = f"{name}-{gname}"
561560
var_key_map[name] = gname_l
562561

563-
key: tuple[Any, ...] = (gname_l,)
564-
for dim in variable.dims:
565-
if dim in chunk_index:
566-
key += (chunk_index[dim],)
567-
else:
568-
# unchunked dimensions in the input have one chunk in the result
569-
# output can have new dimensions with exactly one chunk
570-
key += (0,)
562+
# unchunked dimensions in the input have one chunk in the result
563+
# output can have new dimensions with exactly one chunk
564+
key: tuple[Any, ...] = (gname_l,) + tuple(
565+
chunk_index[dim] if dim in chunk_index else 0 for dim in variable.dims
566+
)
571567

572568
# We're adding multiple new layers to the graph:
573569
# The first new layer is the result of the computation on

0 commit comments

Comments
 (0)