def test_set_index_with_explicit_divisions():
    df = pd.DataFrame({'x': [4, 1, 2, 5]}, index=[10, 20, 30, 40])
    ddf = dd.from_pandas(df, npartitions=2)

    def throw(*args, **kwargs):
        raise Exception()
    with dask.config.set(get=throw):
        ddf2 = ddf.set_index('x', divisions=[1, 3, 5])
    assert (ddf2.divisions == (1, 3, 5))
    df2 = df.set_index('x')
    assert_eq(ddf2, df2)
    with pytest.raises(ValueError):
        ddf.set_index('x', divisions=[3, 1, 5])
def test_set_index_with_explicit_divisions():
    df = pd.DataFrame({'x': [4, 1, 2, 5]}, index=[10, 20, 30, 40])
    ddf = dd.from_pandas(df, npartitions=2)

    def throw(*args, **kwargs):
        raise Exception()
    with dask.config.set(get=throw):
        ddf2 = ddf.set_index('x', divisions=[1, 3, 5])
    assert (ddf2.divisions == (1, 3, 5))
    df2 = df.set_index('x')
    assert_eq(ddf2, df2)
    with pytest.raises(ValueError):
        ddf.set_index('x', divisions=[3, 1, 5])