MCPcopy
hub / github.com/pydata/xarray / test_shuffle_simple

Function test_shuffle_simple

xarray/tests/test_groupby.py:3363–3376  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3361
3362@requires_dask_ge_2024_08_1
3363def test_shuffle_simple() -> None:
3364 import dask
3365
3366 da = xr.DataArray(
3367 dims="x",
3368 data=dask.array.from_array([1, 2, 3, 4, 5, 6], chunks=2),
3369 coords={"label": ("x", ["a", "b", "c", "a", "b", "c"])},
3370 )
3371 actual = da.groupby(label=UniqueGrouper()).shuffle_to_chunks()
3372 expected = da.isel(x=[0, 3, 1, 4, 2, 5])
3373 assert_identical(actual, expected)
3374
3375 with pytest.raises(ValueError):
3376 da.chunk(x=2, eagerly_load_group=False).groupby("label").shuffle_to_chunks()
3377
3378
3379@requires_dask_ge_2024_08_1

Callers

nothing calls this directly

Calls 8

groupbyMethod · 0.95
iselMethod · 0.95
chunkMethod · 0.95
UniqueGrouperClass · 0.90
assert_identicalFunction · 0.90
from_arrayMethod · 0.45
shuffle_to_chunksMethod · 0.45
groupbyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…