MCPcopy
hub / github.com/dask/dask / _validate_chunks

Method _validate_chunks

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

Source from the content-addressed store, hash-verified

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