|
4 | 4 | from pandas._libs import index as libindex |
5 | 5 |
|
6 | 6 | import pandas as pd |
7 | | -from pandas import Categorical |
| 7 | +from pandas import Categorical, CategoricalDtype |
8 | 8 | import pandas._testing as tm |
9 | 9 | from pandas.core.indexes.api import CategoricalIndex, Index |
10 | 10 |
|
@@ -306,18 +306,19 @@ def test_drop_duplicates(self, data, categories, expected): |
306 | 306 | tm.assert_index_equal(result, e) |
307 | 307 |
|
308 | 308 | @pytest.mark.parametrize( |
309 | | - "data, categories, expected_data, expected_categories", |
| 309 | + "data, categories, expected_data", |
310 | 310 | [ |
311 | | - ([1, 1, 1], [1, 2, 3], [1], [1]), |
312 | | - ([1, 1, 1], list("abc"), [np.nan], []), |
313 | | - ([1, 2, "a"], [1, 2, 3], [1, 2, np.nan], [1, 2]), |
314 | | - ([2, "a", "b"], list("abc"), [np.nan, "a", "b"], ["a", "b"]), |
| 311 | + ([1, 1, 1], [1, 2, 3], [1]), |
| 312 | + ([1, 1, 1], list("abc"), [np.nan]), |
| 313 | + ([1, 2, "a"], [1, 2, 3], [1, 2, np.nan]), |
| 314 | + ([2, "a", "b"], list("abc"), [np.nan, "a", "b"]), |
315 | 315 | ], |
316 | 316 | ) |
317 | | - def test_unique(self, data, categories, expected_data, expected_categories): |
| 317 | + def test_unique(self, data, categories, expected_data, ordered): |
| 318 | + dtype = CategoricalDtype(categories, ordered=ordered) |
318 | 319 |
|
319 | | - idx = CategoricalIndex(data, categories=categories) |
320 | | - expected = CategoricalIndex(expected_data, categories=expected_categories) |
| 320 | + idx = CategoricalIndex(data, dtype=dtype) |
| 321 | + expected = CategoricalIndex(expected_data, dtype=dtype) |
321 | 322 | tm.assert_index_equal(idx.unique(), expected) |
322 | 323 |
|
323 | 324 | def test_repr_roundtrip(self): |
|
0 commit comments