Repository: dask/dask
File: dask/dataframe/tests/test_dataframe.py (Python)

Code before:
            ctx = (
                pytest.warns(
                    FutureWarning, match="Will be removed in a future version."
                )
                if not PANDAS_GE_210
                else contextlib.nullcontext()
            )

            with _check_warning(PANDAS_GE_210, FutureWarning, method), ctx:
                actual = f(ddf, offset)
            assert_eq(actual, expected)

            with _check_warning(PANDAS_GE_210, FutureWarning, method):
                expected = f(df.A, offset)
            with _check_warning(PANDAS_GE_210, FutureWarning, method), ctx:
                actual = f(ddf.A, offset)
            assert_eq(actual, expected)


@pytest.mark.parametrize("npartitions", [1, 4, 20])
@pytest.mark.parametrize("split_every", [2, 5])
@pytest.mark.parametrize("split_out", [None, 1, 5, 20])
def test_hash_split_unique(npartitions, split_every, split_out):
    if DASK_EXPR_ENABLED and split_out is None:
        # no longer supported
        return
    from string import ascii_lowercase

    s = pd.Series(np.random.choice(list(ascii_lowercase), 1000, replace=True))
    ds = dd.from_pandas(s, npartitions=npartitions)

    dropped = ds.unique(split_every=split_every, split_out=split_out)

    dsk = dropped.__dask_optimize__(dropped.dask, dropped.__dask_keys__())
    from dask.core import get_deps

    dependencies, dependents = get_deps(dsk)

    if not DASK_EXPR_ENABLED:
        # dask-expr shuffles which messes this up
        assert len([k for k, v in dependencies.items() if not v]) == npartitions
    assert dropped.npartitions == (split_out or 1)
    assert sorted(dropped.compute(scheduler="sync")) == sorted(s.unique())


@pytest.mark.parametrize("split_every", [None, 2])
def test_split_out_drop_duplicates(split_every):
    x = np.concatenate([np.arange(10)] * 100)[:, None]
    y = x.copy()
    z = np.concatenate([np.arange(20)] * 50)[:, None]
    rs = np.random.RandomState(1)

Review comment (suggestion):
```suggestion
        pytest.skip("no longer supported")
```

Code after:
            ctx = (
                pytest.warns(
                    FutureWarning, match="Will be removed in a future version."
                )
                if not PANDAS_GE_210
                else contextlib.nullcontext()
            )

            with _check_warning(PANDAS_GE_210, FutureWarning, method), ctx:
                actual = f(ddf, offset)
            assert_eq(actual, expected)

            with _check_warning(PANDAS_GE_210, FutureWarning, method):
                expected = f(df.A, offset)
            with _check_warning(PANDAS_GE_210, FutureWarning, method), ctx:
                actual = f(ddf.A, offset)
            assert_eq(actual, expected)


@pytest.mark.parametrize("npartitions", [1, 4, 20])
@pytest.mark.parametrize("split_every", [2, 5])
@pytest.mark.parametrize("split_out", [None, 1, 5, 20])
def test_hash_split_unique(npartitions, split_every, split_out):
    if DASK_EXPR_ENABLED and split_out is None:
        pytest.skip("no longer supported")
    from string import ascii_lowercase

    s = pd.Series(np.random.choice(list(ascii_lowercase), 1000, replace=True))
    ds = dd.from_pandas(s, npartitions=npartitions)

    dropped = ds.unique(split_every=split_every, split_out=split_out)

    dsk = dropped.__dask_optimize__(dropped.dask, dropped.__dask_keys__())
    from dask.core import get_deps

    dependencies, dependents = get_deps(dsk)

    if not DASK_EXPR_ENABLED:
        # dask-expr shuffles which messes this up
        assert len([k for k, v in dependencies.items() if not v]) == npartitions
    assert dropped.npartitions == (split_out or 1)
    assert sorted(dropped.compute(scheduler="sync")) == sorted(s.unique())


@pytest.mark.parametrize("split_every", [None, 2])
def test_split_out_drop_duplicates(split_every):
    x = np.concatenate([np.arange(10)] * 100)[:, None]
    y = x.copy()
    z = np.concatenate([np.arange(20)] * 50)[:, None]
    rs = np.random.RandomState(1)
    rs.shuffle(x)