Skip to content

Commit e99033e

Browse files
committed
Use list comprehension
1 parent 3035752 commit e99033e

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

xarray/core/parallel.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def check_result_variables(
5555
)
5656

5757

58-
def subset_dataset_to_chunk(graph, gname, dataset, input_chunks, chunk_tuple):
58+
def subset_dataset_to_block(graph, gname, dataset, input_chunks, chunk_tuple):
5959

6060
# mapping from dimension name to chunk index
6161
input_chunk_index = dict(zip(input_chunks.keys(), chunk_tuple))
@@ -420,16 +420,12 @@ def _wrapper(func, args, kwargs, arg_is_array, expected):
420420
# mapping from dimension name to chunk index
421421
input_chunk_index = dict(zip(input_chunks.keys(), chunk_tuple))
422422

423-
chunked_args = []
424-
for arg in (dataset,) + tuple(converted_args):
425-
if isinstance(arg, (DataArray, Dataset)):
426-
chunked_args.append(
427-
subset_dataset_to_chunk(
428-
graph, gname, arg, input_chunks, chunk_tuple
429-
)
430-
)
431-
else:
432-
chunked_args.append(arg)
423+
blocked_args = [
424+
subset_dataset_to_block(graph, gname, arg, input_chunks, chunk_tuple)
425+
if isinstance(arg, (DataArray, Dataset))
426+
else arg
427+
for arg in (dataset,) + tuple(converted_args)
428+
]
433429

434430
# expected["shapes", "coords", "data_vars"] are used to raise nice error messages in _wrapper
435431
expected = {}
@@ -447,7 +443,7 @@ def _wrapper(func, args, kwargs, arg_is_array, expected):
447443
graph[from_wrapper] = (
448444
_wrapper,
449445
func,
450-
chunked_args,
446+
blocked_args,
451447
kwargs,
452448
[input_is_array] + arg_is_array,
453449
expected,

0 commit comments

Comments
 (0)