Skip to content

Commit 9b5e4cc

Browse files
committed
Small speedup
1 parent b9974b4 commit 9b5e4cc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

xarray/core/parallel.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ def subset_dataset_to_block(
472472
dim: _get_chunk_slicer(dim, chunk_index, input_chunk_bounds)
473473
for dim in variable.dims
474474
}
475-
subset = variable.isel(subsetter)
476475
if set(variable.dims) < chunk_dims_set:
477476
# We are including a dimension coordinate,
478477
# minimize duplication by not copying it in the graph for every chunk.
@@ -486,6 +485,7 @@ def subset_dataset_to_block(
486485
f"{name}-{gname}-{dask.base.tokenize(subsetter)}",
487486
) + this_var_chunk_tuple
488487
if chunk_variable_task not in graph:
488+
subset = variable.isel(subsetter)
489489
graph[chunk_variable_task] = (
490490
tuple,
491491
[subset.dims, subset._data, subset.attrs],
@@ -522,7 +522,9 @@ def subset_dataset_to_block(
522522
expected["data_vars"] = set(template.data_vars.keys()) # type: ignore[assignment]
523523
expected["coords"] = set(template.coords.keys()) # type: ignore[assignment]
524524
expected["indexes"] = {
525-
dim: coordinates.xindexes[dim][_get_chunk_slicer(dim, chunk_index, output_chunk_bounds)]
525+
dim: coordinates.xindexes[dim][
526+
_get_chunk_slicer(dim, chunk_index, output_chunk_bounds)
527+
]
526528
for dim in coordinates.xindexes
527529
}
528530

0 commit comments

Comments
 (0)