Skip to content

Commit 9e44182

Browse files
jschendeljreback
authored andcommitted
TST: Add tests for Categorical.is_dtype_equal against Series (#19045)
1 parent f5fc3a0 commit 9e44182

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pandas/tests/categorical/test_dtypes.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pandas.util.testing as tm
88
from pandas.core.dtypes.dtypes import CategoricalDtype
9-
from pandas import Categorical, Index, CategoricalIndex
9+
from pandas import Categorical, Index, CategoricalIndex, Series
1010

1111

1212
class TestCategoricalDtypes(object):
@@ -30,6 +30,17 @@ def test_is_equal_dtype(self):
3030
CategoricalIndex(c1, categories=list('cab'))))
3131
assert not c1.is_dtype_equal(CategoricalIndex(c1, ordered=True))
3232

33+
# GH 16659
34+
s1 = Series(c1)
35+
s2 = Series(c2)
36+
s3 = Series(c3)
37+
assert c1.is_dtype_equal(s1)
38+
assert c2.is_dtype_equal(s2)
39+
assert c3.is_dtype_equal(s3)
40+
assert c1.is_dtype_equal(s2)
41+
assert not c1.is_dtype_equal(s3)
42+
assert not c1.is_dtype_equal(s1.astype(object))
43+
3344
def test_set_dtype_same(self):
3445
c = Categorical(['a', 'b', 'c'])
3546
result = c._set_dtype(CategoricalDtype(['a', 'b', 'c']))

0 commit comments

Comments
 (0)