Skip to content

Commit fd8008b

Browse files
committed
CLN: use fixture for ordered
1 parent 455a2cd commit fd8008b

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

pandas/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ def observed(request):
126126
return request.param
127127

128128

129+
@pytest.fixture(params=[True, False, None])
130+
def ordered(request):
131+
"""Boolean 'ordered' parameter for Categorical."""
132+
return request.param
133+
134+
129135
_all_arithmetic_operators = ['__add__', '__radd__',
130136
'__sub__', '__rsub__',
131137
'__mul__', '__rmul__',

pandas/tests/arrays/categorical/conftest.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,3 @@
55
def allow_fill(request):
66
"""Boolean 'allow_fill' parameter for Categorical.take"""
77
return request.param
8-
9-
10-
@pytest.fixture(params=[True, False])
11-
def ordered(request):
12-
"""Boolean 'ordered' parameter for Categorical."""
13-
return request.param

pandas/tests/dtypes/test_dtypes.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
import pandas.util.testing as tm
2121

2222

23-
@pytest.fixture(params=[True, False, None])
24-
def ordered(request):
25-
return request.param
26-
27-
2823
class Base(object):
2924

3025
def setup_method(self, method):

pandas/tests/series/test_analytics.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,14 +1406,13 @@ def test_value_counts_with_nan(self):
14061406
pytest.param("datetime64[D]",
14071407
marks=pytest.mark.xfail(reason="GH#7996"))]
14081408
)
1409-
@pytest.mark.parametrize("is_ordered", [True, False])
1410-
def test_drop_duplicates_categorical_non_bool(self, dtype, is_ordered):
1409+
def test_drop_duplicates_categorical_non_bool(self, dtype, ordered):
14111410
cat_array = np.array([1, 2, 3, 4, 5], dtype=np.dtype(dtype))
14121411

14131412
# Test case 1
14141413
input1 = np.array([1, 2, 3, 3], dtype=np.dtype(dtype))
14151414
tc1 = Series(Categorical(input1, categories=cat_array,
1416-
ordered=is_ordered))
1415+
ordered=ordered))
14171416

14181417
expected = Series([False, False, False, True])
14191418
tm.assert_series_equal(tc1.duplicated(), expected)
@@ -1440,7 +1439,7 @@ def test_drop_duplicates_categorical_non_bool(self, dtype, is_ordered):
14401439
# Test case 2
14411440
input2 = np.array([1, 2, 3, 5, 3, 2, 4], dtype=np.dtype(dtype))
14421441
tc2 = Series(Categorical(
1443-
input2, categories=cat_array, ordered=is_ordered)
1442+
input2, categories=cat_array, ordered=ordered)
14441443
)
14451444

14461445
expected = Series([False, False, False, False, True, True, False])
@@ -1465,10 +1464,9 @@ def test_drop_duplicates_categorical_non_bool(self, dtype, is_ordered):
14651464
sc.drop_duplicates(keep=False, inplace=True)
14661465
tm.assert_series_equal(sc, tc2[~expected])
14671466

1468-
@pytest.mark.parametrize("is_ordered", [True, False])
1469-
def test_drop_duplicates_categorical_bool(self, is_ordered):
1467+
def test_drop_duplicates_categorical_bool(self, ordered):
14701468
tc = Series(Categorical([True, False, True, False],
1471-
categories=[True, False], ordered=is_ordered))
1469+
categories=[True, False], ordered=ordered))
14721470

14731471
expected = Series([False, False, True, True])
14741472
tm.assert_series_equal(tc.duplicated(), expected)

0 commit comments

Comments
 (0)