def test_set_index_categorical():
    order = list(reversed(string.ascii_letters))
    values = list(string.ascii_letters)
    random.shuffle(values)
    dtype = pd.api.types.CategoricalDtype(order, ordered=True)
    df = pd.DataFrame({'A': pd.Categorical(values, dtype=dtype), 'B': 1})
    result = dd.from_pandas(df, npartitions=2).set_index('A')
    assert (len(result) == len(df))
    divisions = pd.Categorical(result.divisions, dtype=dtype)
    assert_categorical_equal(divisions, divisions.sort_values())
def test_set_index_categorical():
    order = list(reversed(string.ascii_letters))
    values = list(string.ascii_letters)
    random.shuffle(values)
    dtype = pd.api.types.CategoricalDtype(order, ordered=True)
    df = pd.DataFrame({'A': pd.Categorical(values, dtype=dtype), 'B': 1})
    result = dd.from_pandas(df, npartitions=2).set_index('A')
    assert (len(result) == len(df))
    divisions = pd.Categorical(result.divisions, dtype=dtype)
    assert_categorical_equal(divisions, divisions.sort_values())