|
13 | 13 |
|
14 | 14 | class TestReindex:
|
15 | 15 | def test_reindex_dtype(self):
|
16 |
| - c = CategoricalIndex(["a", "b", "c", "a"]) |
17 |
| - res, indexer = c.reindex(["a", "c"]) |
| 16 | + # GH#11586 |
| 17 | + ci = CategoricalIndex(["a", "b", "c", "a"]) |
| 18 | + with tm.assert_produces_warning(FutureWarning, match="non-unique"): |
| 19 | + res, indexer = ci.reindex(["a", "c"]) |
| 20 | + |
18 | 21 | tm.assert_index_equal(res, Index(["a", "a", "c"]), exact=True)
|
19 | 22 | tm.assert_numpy_array_equal(indexer, np.array([0, 3, 2], dtype=np.intp))
|
20 | 23 |
|
21 |
| - c = CategoricalIndex(["a", "b", "c", "a"]) |
22 |
| - res, indexer = c.reindex(Categorical(["a", "c"])) |
| 24 | + ci = CategoricalIndex(["a", "b", "c", "a"]) |
| 25 | + with tm.assert_produces_warning(FutureWarning, match="non-unique"): |
| 26 | + res, indexer = ci.reindex(Categorical(["a", "c"])) |
23 | 27 |
|
24 | 28 | exp = CategoricalIndex(["a", "a", "c"], categories=["a", "c"])
|
25 | 29 | tm.assert_index_equal(res, exp, exact=True)
|
26 | 30 | tm.assert_numpy_array_equal(indexer, np.array([0, 3, 2], dtype=np.intp))
|
27 | 31 |
|
28 |
| - c = CategoricalIndex(["a", "b", "c", "a"], categories=["a", "b", "c", "d"]) |
29 |
| - res, indexer = c.reindex(["a", "c"]) |
| 32 | + ci = CategoricalIndex(["a", "b", "c", "a"], categories=["a", "b", "c", "d"]) |
| 33 | + with tm.assert_produces_warning(FutureWarning, match="non-unique"): |
| 34 | + res, indexer = ci.reindex(["a", "c"]) |
30 | 35 | exp = Index(["a", "a", "c"], dtype="object")
|
31 | 36 | tm.assert_index_equal(res, exp, exact=True)
|
32 | 37 | tm.assert_numpy_array_equal(indexer, np.array([0, 3, 2], dtype=np.intp))
|
33 | 38 |
|
34 |
| - c = CategoricalIndex(["a", "b", "c", "a"], categories=["a", "b", "c", "d"]) |
35 |
| - res, indexer = c.reindex(Categorical(["a", "c"])) |
| 39 | + ci = CategoricalIndex(["a", "b", "c", "a"], categories=["a", "b", "c", "d"]) |
| 40 | + with tm.assert_produces_warning(FutureWarning, match="non-unique"): |
| 41 | + res, indexer = ci.reindex(Categorical(["a", "c"])) |
36 | 42 | exp = CategoricalIndex(["a", "a", "c"], categories=["a", "c"])
|
37 | 43 | tm.assert_index_equal(res, exp, exact=True)
|
38 | 44 | tm.assert_numpy_array_equal(indexer, np.array([0, 3, 2], dtype=np.intp))
|
|
0 commit comments