Skip to content

Manual Backport PR #45731 on branch 1.4.x (TST: Add @td.skip_if_no_scipy to failing test) #45739

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
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
26 changes: 15 additions & 11 deletions pandas/tests/series/methods/test_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
isna,
)
import pandas._testing as tm
from pandas.util.version import Version


@pytest.fixture(
Expand Down Expand Up @@ -778,7 +779,8 @@ def test_interp_non_timedelta_index(self, interp_methods_ind, ind):
with pytest.raises(ValueError, match=expected_error):
df[0].interpolate(method=method, **kwargs)

def test_interpolate_timedelta_index(self, interp_methods_ind):
@td.skip_if_no_scipy
def test_interpolate_timedelta_index(self, request, interp_methods_ind):
"""
Tests for non numerical index types - object, period, timedelta
Note that all methods except time, index, nearest and values
Expand All @@ -789,17 +791,19 @@ def test_interpolate_timedelta_index(self, interp_methods_ind):
df = pd.DataFrame([0, 1, np.nan, 3], index=ind)

method, kwargs = interp_methods_ind
if method == "pchip":
pytest.importorskip("scipy")

if method in {"linear", "pchip"}:
result = df[0].interpolate(method=method, **kwargs)
expected = Series([0.0, 1.0, 2.0, 3.0], name=0, index=ind)
tm.assert_series_equal(result, expected)
else:
pytest.skip(
"This interpolation method is not supported for Timedelta Index yet."
import scipy

if method in {"cubic", "zero"} or (
method == "barycentric" and Version(scipy.__version__) < Version("1.5.0")
):
request.node.add_marker(
pytest.mark.xfail(
reason=f"{method} interpolation is not supported for TimedeltaIndex"
)
)
result = df[0].interpolate(method=method, **kwargs)
expected = Series([0.0, 1.0, 2.0, 3.0], name=0, index=ind)
tm.assert_series_equal(result, expected)

@pytest.mark.parametrize(
"ascending, expected_values",
Expand Down