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

Method _validate_chunks

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

Source from the content-addressed store, hash-verified

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