Skip to content

CLN/TST: remove used-once fixtures #44890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pandas/_testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@
+ BYTES_DTYPES
)

NARROW_NP_DTYPES = [
np.float16,
np.float32,
np.int8,
np.int16,
np.int32,
np.uint8,
np.uint16,
np.uint32,
]

NULL_OBJECTS = [None, np.nan, pd.NaT, float("nan"), pd.NA, Decimal("NaN")]
NP_NAT_OBJECTS = [
cls("NaT", unit)
Expand Down
31 changes: 1 addition & 30 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,6 @@ def index_with_missing(request):
# ----------------------------------------------------------------
# Series'
# ----------------------------------------------------------------
@pytest.fixture
def empty_series():
return Series([], index=[], dtype=np.float64)


@pytest.fixture
def string_series():
"""
Expand Down Expand Up @@ -672,31 +667,12 @@ def series_with_multilevel_index():
return ser


_narrow_dtypes = [
np.float16,
np.float32,
np.int8,
np.int16,
np.int32,
np.uint8,
np.uint16,
np.uint32,
]
_narrow_series = {
f"{dtype.__name__}-series": tm.makeFloatSeries(name="a").astype(dtype)
for dtype in _narrow_dtypes
for dtype in tm.NARROW_NP_DTYPES
}


@pytest.fixture(params=_narrow_series.keys())
def narrow_series(request):
"""
Fixture for Series with low precision data types
"""
# copy to avoid mutation, e.g. setting .name
return _narrow_series[request.param].copy()


_index_or_series_objs = {**indices_dict, **_series, **_narrow_series}


Expand All @@ -712,11 +688,6 @@ def index_or_series_obj(request):
# ----------------------------------------------------------------
# DataFrames
# ----------------------------------------------------------------
@pytest.fixture
def empty_frame():
return DataFrame()


@pytest.fixture
def int_frame():
"""
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/base/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Index,
Series,
)
import pandas._testing as tm


@pytest.mark.parametrize(
Expand Down Expand Up @@ -109,8 +110,9 @@ def test_memory_usage_components_series(series_with_simple_index):
assert total_usage == non_index_usage + index_usage


def test_memory_usage_components_narrow_series(narrow_series):
series = narrow_series
@pytest.mark.parametrize("dtype", tm.NARROW_NP_DTYPES)
def test_memory_usage_components_narrow_series(dtype):
series = tm.makeFloatSeries(name="a").astype(dtype)
total_usage = series.memory_usage(index=True)
non_index_usage = series.memory_usage(index=False)
index_usage = series.index.memory_usage()
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/frame/methods/test_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1384,8 +1384,9 @@ def test_replace_value_category_type(self):

@pytest.mark.xfail(
reason="category dtype gets changed to object type after replace, see #35268",
raises=AssertionError,
)
def test_replace_dict_category_type(self, input_category_df, expected_category_df):
def test_replace_dict_category_type(self):
"""
Test to ensure category dtypes are maintained
after replace with dict values
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/io/json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ def test_roundtrip_categorical(self, request, orient, convert_axes, numpy):

@pytest.mark.parametrize("convert_axes", [True, False])
@pytest.mark.parametrize("numpy", [True, False])
def test_roundtrip_empty(self, orient, convert_axes, numpy, empty_frame):
def test_roundtrip_empty(self, orient, convert_axes, numpy):
empty_frame = DataFrame()
data = empty_frame.to_json(orient=orient)
result = read_json(data, orient=orient, convert_axes=convert_axes, numpy=numpy)
expected = empty_frame.copy()
Expand Down Expand Up @@ -673,7 +674,8 @@ def test_series_roundtrip_object(self, orient, numpy, dtype, object_series):
tm.assert_series_equal(result, expected)

@pytest.mark.parametrize("numpy", [True, False])
def test_series_roundtrip_empty(self, orient, numpy, empty_series):
def test_series_roundtrip_empty(self, orient, numpy):
empty_series = Series([], index=[], dtype=np.float64)
data = empty_series.to_json(orient=orient)
result = read_json(data, typ="series", orient=orient, numpy=numpy)

Expand Down