Skip to content

Commit 23dd988

Browse files
committed
TST: parametrize & change test case
1 parent 3114f4d commit 23dd988

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

pandas/tests/arrays/categorical/test_missing.py

+15-13
Original file line numberDiff line numberDiff line change
@@ -149,21 +149,23 @@ def test_use_inf_as_na_outside_context(self, values, expected):
149149
expected = DataFrame(expected)
150150
tm.assert_frame_equal(result, expected)
151151

152-
def test_compare_categorical_with_missing(self):
152+
@pytest.mark.parametrize(
153+
"a1, a2, categories",
154+
[
155+
(["a", "b", "c"], [np.nan, "a", "b"], ["a", "b", "c"]),
156+
([1, 2, 3], [np.nan, 1, 2], [1, 2, 3]),
157+
],
158+
)
159+
def test_compare_categorical_with_missing(self, a1, a2, categories):
153160
# GH 28384
154-
a1 = ["a", "b", np.nan]
155-
a2 = ["b", "a", "a"]
156-
157-
cat_s1 = Series(a1, dtype="category")
158-
cat_s2 = Series(a2, dtype="category")
159-
result = cat_s1 != cat_s2
161+
cat_type = CategoricalDtype(categories)
160162

161-
expected = Series([True, True, True], dtype="bool")
163+
# !=
164+
result = Series(a1, dtype=cat_type) != Series(a2, dtype=cat_type)
165+
expected = Series(a1) != Series(a2)
162166
tm.assert_series_equal(result, expected)
163167

164-
# categorical vs noncategorical
165-
noncat_s1 = Series(a1)
166-
noncat_s2 = Series(a2)
167-
expected = noncat_s1 != noncat_s2
168-
168+
# ==
169+
result = Series(a1, dtype=cat_type) == Series(a2, dtype=cat_type)
170+
expected = Series(a1) == Series(a2)
169171
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)