MCPcopy Create free account
hub / github.com/dask/dask / _validate_chunks

Method _validate_chunks

dask/dataframe/dask_expr/_collection.py:2462–2485  ·  view source on GitHub ↗
(self, arr, lengths)

Source from the content-addressed store, hash-verified

2460 return records
2461
2462 def _validate_chunks(self, arr, lengths):
2463 from collections.abc import Sequence
2464
2465 from dask.array.core import normalize_chunks
2466
2467 if isinstance(lengths, Sequence):
2468 lengths = tuple(lengths)
2469
2470 if len(lengths) != self.npartitions:
2471 raise ValueError(
2472 "The number of items in 'lengths' does not match the number of "
2473 f"partitions. {len(lengths)} != {self.npartitions}"
2474 )
2475
2476 if self.ndim == 1:
2477 chunks = normalize_chunks((lengths,))
2478 else:
2479 chunks = normalize_chunks((lengths, (len(self.columns),)))
2480
2481 return chunks
2482 elif lengths is not None:
2483 raise ValueError(f"Unexpected value for 'lengths': '{lengths}'")
2484
2485 return arr._chunks
2486
2487 def to_bag(self, index=False, format="tuple"):
2488 """Create a Dask Bag from a Series"""

Callers 2

to_dask_arrayMethod · 0.95
to_recordsMethod · 0.95

Calls 1

normalize_chunksFunction · 0.90

Tested by

no test coverage detected