|
8 | 8 |
|
9 | 9 |
|
10 | 10 | class TestCategoricalDtypes:
|
11 |
| - def test_is_equal_dtype(self): |
| 11 | + def test_is_dtype_equal_deprecated(self): |
| 12 | + # GH#37545 |
| 13 | + c1 = Categorical(list("aabca"), categories=list("abc"), ordered=False) |
| 14 | + |
| 15 | + with tm.assert_produces_warning(FutureWarning): |
| 16 | + c1.is_dtype_equal(c1) |
| 17 | + |
| 18 | + def test_categories_match_up_to_permutation(self): |
12 | 19 |
|
13 | 20 | # test dtype comparisons between cats
|
14 | 21 |
|
15 | 22 | c1 = Categorical(list("aabca"), categories=list("abc"), ordered=False)
|
16 | 23 | c2 = Categorical(list("aabca"), categories=list("cab"), ordered=False)
|
17 | 24 | c3 = Categorical(list("aabca"), categories=list("cab"), ordered=True)
|
18 |
| - assert c1.is_dtype_equal(c1) |
19 |
| - assert c2.is_dtype_equal(c2) |
20 |
| - assert c3.is_dtype_equal(c3) |
21 |
| - assert c1.is_dtype_equal(c2) |
22 |
| - assert not c1.is_dtype_equal(c3) |
23 |
| - assert not c1.is_dtype_equal(Index(list("aabca"))) |
24 |
| - assert not c1.is_dtype_equal(c1.astype(object)) |
25 |
| - assert c1.is_dtype_equal(CategoricalIndex(c1)) |
26 |
| - assert c1.is_dtype_equal(CategoricalIndex(c1, categories=list("cab"))) |
27 |
| - assert not c1.is_dtype_equal(CategoricalIndex(c1, ordered=True)) |
| 25 | + assert c1._categories_match_up_to_permutation(c1) |
| 26 | + assert c2._categories_match_up_to_permutation(c2) |
| 27 | + assert c3._categories_match_up_to_permutation(c3) |
| 28 | + assert c1._categories_match_up_to_permutation(c2) |
| 29 | + assert not c1._categories_match_up_to_permutation(c3) |
| 30 | + assert not c1._categories_match_up_to_permutation(Index(list("aabca"))) |
| 31 | + assert not c1._categories_match_up_to_permutation(c1.astype(object)) |
| 32 | + assert c1._categories_match_up_to_permutation(CategoricalIndex(c1)) |
| 33 | + assert c1._categories_match_up_to_permutation( |
| 34 | + CategoricalIndex(c1, categories=list("cab")) |
| 35 | + ) |
| 36 | + assert not c1._categories_match_up_to_permutation( |
| 37 | + CategoricalIndex(c1, ordered=True) |
| 38 | + ) |
28 | 39 |
|
29 | 40 | # GH 16659
|
30 | 41 | s1 = Series(c1)
|
31 | 42 | s2 = Series(c2)
|
32 | 43 | s3 = Series(c3)
|
33 |
| - assert c1.is_dtype_equal(s1) |
34 |
| - assert c2.is_dtype_equal(s2) |
35 |
| - assert c3.is_dtype_equal(s3) |
36 |
| - assert c1.is_dtype_equal(s2) |
37 |
| - assert not c1.is_dtype_equal(s3) |
38 |
| - assert not c1.is_dtype_equal(s1.astype(object)) |
| 44 | + assert c1._categories_match_up_to_permutation(s1) |
| 45 | + assert c2._categories_match_up_to_permutation(s2) |
| 46 | + assert c3._categories_match_up_to_permutation(s3) |
| 47 | + assert c1._categories_match_up_to_permutation(s2) |
| 48 | + assert not c1._categories_match_up_to_permutation(s3) |
| 49 | + assert not c1._categories_match_up_to_permutation(s1.astype(object)) |
39 | 50 |
|
40 | 51 | def test_set_dtype_same(self):
|
41 | 52 | c = Categorical(["a", "b", "c"])
|
|
0 commit comments