Skip to content

Commit 8b95da8

Browse files
authored
Flexible Indexes: Avoid len(index) in map_blocks (#5670)
1 parent 8f5b4a1 commit 8b95da8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

xarray/core/parallel.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,10 @@ def _wrapper(
295295
# check that index lengths and values are as expected
296296
for name, index in result.xindexes.items():
297297
if name in expected["shapes"]:
298-
if len(index) != expected["shapes"][name]:
298+
if result.sizes[name] != expected["shapes"][name]:
299299
raise ValueError(
300-
f"Received dimension {name!r} of length {len(index)}. Expected length {expected['shapes'][name]}."
300+
f"Received dimension {name!r} of length {result.sizes[name]}. "
301+
f"Expected length {expected['shapes'][name]}."
301302
)
302303
if name in expected["indexes"]:
303304
expected_index = expected["indexes"][name]
@@ -568,8 +569,8 @@ def subset_dataset_to_block(
568569
for dim in dims:
569570
if dim in output_chunks:
570571
var_chunks.append(output_chunks[dim])
571-
elif dim in indexes:
572-
var_chunks.append((len(indexes[dim]),))
572+
elif dim in result.xindexes:
573+
var_chunks.append((result.sizes[dim],))
573574
elif dim in template.dims:
574575
# new unindexed dimension
575576
var_chunks.append((template.sizes[dim],))

0 commit comments

Comments
 (0)