@pytest.mark.parametrize('engine', ['pandas', pytest.param('cudf', marks=pytest.mark.gpu)])
def test_set_index(engine):
    if (engine == 'cudf'):
        dask_cudf = pytest.importorskip('dask_cudf')
    dsk = {('x', 0): pd.DataFrame({'a': [1, 2, 3], 'b': [4, 2, 6]}, index=[0, 1, 3]), ('x', 1): pd.DataFrame({'a': [4, 5, 6], 'b': [3, 5, 8]}, index=[5, 6, 8]), ('x', 2): pd.DataFrame({'a': [7, 8, 9], 'b': [9, 1, 8]}, index=[9, 9, 9])}
    d = dd.DataFrame(dsk, 'x', meta, [0, 4, 9, 9])
    if (engine == 'cudf'):
        d = dask_cudf.from_dask_dataframe(d)
    full = d.compute()
    d2 = d.set_index('b', npartitions=3)
    assert (d2.npartitions == 3)
    assert (d2.index.name == 'b')
    assert_eq(d2, full.set_index('b'))
    d3 = d.set_index(d.b, npartitions=3)
    assert (d3.npartitions == 3)
    assert (d3.index.name == 'b')
    assert_eq(d3, full.set_index(full.b))
    d4 = d.set_index('b')
    assert (d4.index.name == 'b')
    assert_eq(d4, full.set_index('b'))
    d5 = d.set_index(['b'])
    assert (d5.index.name == 'b')
    assert_eq(d5, full.set_index(['b']))
@pytest.mark.parametrize('engine', ['pandas', pytest.param('cudf', marks=pytest.mark.gpu)])
def test_set_index(engine):
    if (engine == 'cudf'):
        dask_cudf = pytest.importorskip('dask_cudf')
    dsk = {('x', 0): pd.DataFrame({'a': [1, 2, 3], 'b': [4, 2, 6]}, index=[0, 1, 3]), ('x', 1): pd.DataFrame({'a': [4, 5, 6], 'b': [3, 5, 8]}, index=[5, 6, 8]), ('x', 2): pd.DataFrame({'a': [7, 8, 9], 'b': [9, 1, 8]}, index=[9, 9, 9])}
    d = dd.DataFrame(dsk, 'x', meta, [0, 4, 9, 9])
    if (engine == 'cudf'):
        d = dask_cudf.from_dask_dataframe(d)
    full = d.compute()
    d2 = d.set_index('b', npartitions=3)
    assert (d2.npartitions == 3)
    assert (d2.index.name == 'b')
    assert_eq(d2, full.set_index('b'))
    d3 = d.set_index(d.b, npartitions=3)
    assert (d3.npartitions == 3)
    assert (d3.index.name == 'b')
    assert_eq(d3, full.set_index(full.b))
    d4 = d.set_index('b')
    assert (d4.index.name == 'b')
    assert_eq(d4, full.set_index('b'))
    d5 = d.set_index(['b'])
    assert (d5.index.name == 'b')
    assert_eq(d5, full.set_index(['b']))