def test_set_index_sorted_true():
    df = pd.DataFrame({'x': [1, 2, 3, 4], 'y': [10, 20, 20, 40], 'z': [4, 3, 2, 1]})
    a = dd.from_pandas(df, 2, sort=False)
    assert (not a.known_divisions)
    b = a.set_index('x', sorted=True)
    assert b.known_divisions
    assert set(a.dask).issubset(set(b.dask))
    for drop in [True, False]:
        assert_eq(a.set_index('x', drop=drop), df.set_index('x', drop=drop))
        assert_eq(a.set_index(a.x, sorted=True, drop=drop), df.set_index(df.x, drop=drop))
        assert_eq(a.set_index((a.x + 1), sorted=True, drop=drop), df.set_index((df.x + 1), drop=drop))
    with pytest.raises(ValueError):
        a.set_index(a.z, sorted=True)
def test_set_index_sorted_true():
    df = pd.DataFrame({'x': [1, 2, 3, 4], 'y': [10, 20, 20, 40], 'z': [4, 3, 2, 1]})
    a = dd.from_pandas(df, 2, sort=False)
    assert (not a.known_divisions)
    b = a.set_index('x', sorted=True)
    assert b.known_divisions
    assert set(a.dask).issubset(set(b.dask))
    for drop in [True, False]:
        assert_eq(a.set_index('x', drop=drop), df.set_index('x', drop=drop))
        assert_eq(a.set_index(a.x, sorted=True, drop=drop), df.set_index(df.x, drop=drop))
        assert_eq(a.set_index((a.x + 1), sorted=True, drop=drop), df.set_index((df.x + 1), drop=drop))
    with pytest.raises(ValueError):
        a.set_index(a.z, sorted=True)