Skip to content

Commit 7fbb8d1

Browse files
authored
CLN/TST: remove used-once fixtures (#44890)
1 parent b53326c commit 7fbb8d1

File tree

5 files changed

+22
-35
lines changed

5 files changed

+22
-35
lines changed

pandas/_testing/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,17 @@
161161
+ BYTES_DTYPES
162162
)
163163

164+
NARROW_NP_DTYPES = [
165+
np.float16,
166+
np.float32,
167+
np.int8,
168+
np.int16,
169+
np.int32,
170+
np.uint8,
171+
np.uint16,
172+
np.uint32,
173+
]
174+
164175
NULL_OBJECTS = [None, np.nan, pd.NaT, float("nan"), pd.NA, Decimal("NaN")]
165176
NP_NAT_OBJECTS = [
166177
cls("NaT", unit)

pandas/conftest.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -599,11 +599,6 @@ def index_with_missing(request):
599599
# ----------------------------------------------------------------
600600
# Series'
601601
# ----------------------------------------------------------------
602-
@pytest.fixture
603-
def empty_series():
604-
return Series([], index=[], dtype=np.float64)
605-
606-
607602
@pytest.fixture
608603
def string_series():
609604
"""
@@ -672,31 +667,12 @@ def series_with_multilevel_index():
672667
return ser
673668

674669

675-
_narrow_dtypes = [
676-
np.float16,
677-
np.float32,
678-
np.int8,
679-
np.int16,
680-
np.int32,
681-
np.uint8,
682-
np.uint16,
683-
np.uint32,
684-
]
685670
_narrow_series = {
686671
f"{dtype.__name__}-series": tm.makeFloatSeries(name="a").astype(dtype)
687-
for dtype in _narrow_dtypes
672+
for dtype in tm.NARROW_NP_DTYPES
688673
}
689674

690675

691-
@pytest.fixture(params=_narrow_series.keys())
692-
def narrow_series(request):
693-
"""
694-
Fixture for Series with low precision data types
695-
"""
696-
# copy to avoid mutation, e.g. setting .name
697-
return _narrow_series[request.param].copy()
698-
699-
700676
_index_or_series_objs = {**indices_dict, **_series, **_narrow_series}
701677

702678

@@ -712,11 +688,6 @@ def index_or_series_obj(request):
712688
# ----------------------------------------------------------------
713689
# DataFrames
714690
# ----------------------------------------------------------------
715-
@pytest.fixture
716-
def empty_frame():
717-
return DataFrame()
718-
719-
720691
@pytest.fixture
721692
def int_frame():
722693
"""

pandas/tests/base/test_misc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Index,
1919
Series,
2020
)
21+
import pandas._testing as tm
2122

2223

2324
@pytest.mark.parametrize(
@@ -109,8 +110,9 @@ def test_memory_usage_components_series(series_with_simple_index):
109110
assert total_usage == non_index_usage + index_usage
110111

111112

112-
def test_memory_usage_components_narrow_series(narrow_series):
113-
series = narrow_series
113+
@pytest.mark.parametrize("dtype", tm.NARROW_NP_DTYPES)
114+
def test_memory_usage_components_narrow_series(dtype):
115+
series = tm.makeFloatSeries(name="a").astype(dtype)
114116
total_usage = series.memory_usage(index=True)
115117
non_index_usage = series.memory_usage(index=False)
116118
index_usage = series.index.memory_usage()

pandas/tests/frame/methods/test_replace.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,8 +1384,9 @@ def test_replace_value_category_type(self):
13841384

13851385
@pytest.mark.xfail(
13861386
reason="category dtype gets changed to object type after replace, see #35268",
1387+
raises=AssertionError,
13871388
)
1388-
def test_replace_dict_category_type(self, input_category_df, expected_category_df):
1389+
def test_replace_dict_category_type(self):
13891390
"""
13901391
Test to ensure category dtypes are maintained
13911392
after replace with dict values

pandas/tests/io/json/test_pandas.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ def test_roundtrip_categorical(self, request, orient, convert_axes, numpy):
244244

245245
@pytest.mark.parametrize("convert_axes", [True, False])
246246
@pytest.mark.parametrize("numpy", [True, False])
247-
def test_roundtrip_empty(self, orient, convert_axes, numpy, empty_frame):
247+
def test_roundtrip_empty(self, orient, convert_axes, numpy):
248+
empty_frame = DataFrame()
248249
data = empty_frame.to_json(orient=orient)
249250
result = read_json(data, orient=orient, convert_axes=convert_axes, numpy=numpy)
250251
expected = empty_frame.copy()
@@ -673,7 +674,8 @@ def test_series_roundtrip_object(self, orient, numpy, dtype, object_series):
673674
tm.assert_series_equal(result, expected)
674675

675676
@pytest.mark.parametrize("numpy", [True, False])
676-
def test_series_roundtrip_empty(self, orient, numpy, empty_series):
677+
def test_series_roundtrip_empty(self, orient, numpy):
678+
empty_series = Series([], index=[], dtype=np.float64)
677679
data = empty_series.to_json(orient=orient)
678680
result = read_json(data, typ="series", orient=orient, numpy=numpy)
679681

0 commit comments

Comments
 (0)