Skip to content
forked from pydata/xarray

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Sep 18, 2024
1 parent bad0744 commit 91e4bd8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions xarray/tests/test_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -1803,3 +1803,27 @@ def test_minimize_graph_size():
# all the other dimensions.
# e.g. previously for 'x', actual == numchunks['y'] * numchunks['z']
assert actual == numchunks[var], (actual, numchunks[var])


@pytest.mark.parametrize(
"chunks, expected_chunks",
[
((1,), (1, 3, 3, 3)),
((10,), (10,)),
],
)
def test_shuffle_by(chunks, expected_chunks):
from xarray.groupers import UniqueGrouper

da = xr.DataArray(
dims="x",
data=dask.array.arange(10, chunks=chunks),
coords={"x": [1, 2, 3, 1, 2, 3, 1, 2, 3, 0]},
name="a",
)
ds = da.to_dataset()

for obj in [ds, da]:
actual = obj.shuffle_by(x=UniqueGrouper())
assert_identical(actual, obj.sortby("x"))
assert actual.chunksizes["x"] == expected_chunks

0 comments on commit 91e4bd8

Please sign in to comment.