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

Method _validate_chunks

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

Source from the content-addressed store, hash-verified

2496 return records
2497
2498 def _validate_chunks(self, arr, lengths):
2499 from collections.abc import Sequence
2500
2501 from dask.array.core import normalize_chunks
2502
2503 if isinstance(lengths, Sequence):
2504 lengths = tuple(lengths)
2505
2506 if len(lengths) != self.npartitions:
2507 raise ValueError(
2508 "The number of items in 'lengths' does not match the number of "
2509 f"partitions. {len(lengths)} != {self.npartitions}"
2510 )
2511
2512 if self.ndim == 1:
2513 chunks = normalize_chunks((lengths,))
2514 else:
2515 chunks = normalize_chunks((lengths, (len(self.columns),)))
2516
2517 return chunks
2518 elif lengths is not None:
2519 raise ValueError(f"Unexpected value for 'lengths': '{lengths}'")
2520
2521 return arr._chunks
2522
2523 def to_bag(self, index=False, format="tuple"):
2524 """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