Skip to content

Commit e37722b

Browse files
committed
CLN: use fixture for ordered
1 parent 190a69e commit e37722b

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
@@ -1408,14 +1408,13 @@ def test_value_counts_with_nan(self):
14081408
pytest.param("datetime64[D]",
14091409
marks=pytest.mark.xfail(reason="GH#7996"))]
14101410
)
1411-
@pytest.mark.parametrize("is_ordered", [True, False])
1412-
def test_drop_duplicates_categorical_non_bool(self, dtype, is_ordered):
1411+
def test_drop_duplicates_categorical_non_bool(self, dtype, ordered):
14131412
cat_array = np.array([1, 2, 3, 4, 5], dtype=np.dtype(dtype))
14141413

14151414
# Test case 1
14161415
input1 = np.array([1, 2, 3, 3], dtype=np.dtype(dtype))
14171416
tc1 = Series(Categorical(input1, categories=cat_array,
1418-
ordered=is_ordered))
1417+
ordered=ordered))
14191418

14201419
expected = Series([False, False, False, True])
14211420
tm.assert_series_equal(tc1.duplicated(), expected)
@@ -1442,7 +1441,7 @@ def test_drop_duplicates_categorical_non_bool(self, dtype, is_ordered):
14421441
# Test case 2
14431442
input2 = np.array([1, 2, 3, 5, 3, 2, 4], dtype=np.dtype(dtype))
14441443
tc2 = Series(Categorical(
1445-
input2, categories=cat_array, ordered=is_ordered)
1444+
input2, categories=cat_array, ordered=ordered)
14461445
)
14471446

14481447
expected = Series([False, False, False, False, True, True, False])
@@ -1467,10 +1466,9 @@ def test_drop_duplicates_categorical_non_bool(self, dtype, is_ordered):
14671466
sc.drop_duplicates(keep=False, inplace=True)
14681467
tm.assert_series_equal(sc, tc2[~expected])
14691468

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

14751473
expected = Series([False, False, True, True])
14761474
tm.assert_series_equal(tc.duplicated(), expected)

0 commit comments

Comments
 (0)