From de5b5d2413203f9c1c26a41536960552e315b481 Mon Sep 17 00:00:00 2001 From: Nicholas Musolino Date: Sat, 9 Feb 2019 12:47:11 -0500 Subject: [PATCH 01/11] BUG: raise accurate exception from Series.interpolate (#24014) --- pandas/core/internals/blocks.py | 7 ++----- pandas/tests/series/test_missing.py | 25 +++++++++++++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index ac7d21de442db..47ee6dacdd001 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -1115,11 +1115,8 @@ def check_int_bool(self, inplace): fill_value=fill_value, coerce=coerce, downcast=downcast) - # try an interp method - try: - m = missing.clean_interp_method(method, **kwargs) - except ValueError: - m = None + # validate the interp method + m = missing.clean_interp_method(method, **kwargs) if m is not None: r = check_int_bool(self, inplace) diff --git a/pandas/tests/series/test_missing.py b/pandas/tests/series/test_missing.py index 985288c439917..b12fed93c8cb6 100644 --- a/pandas/tests/series/test_missing.py +++ b/pandas/tests/series/test_missing.py @@ -1064,19 +1064,32 @@ def test_interp_limit(self): # GH 9217, make sure limit is an int and greater than 0 methods = ['linear', 'time', 'index', 'values', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic', 'barycentric', 'krogh', - 'polynomial', 'spline', 'piecewise_polynomial', None, + 'polynomial', 'spline', 'piecewise_polynomial', 'from_derivatives', 'pchip', 'akima'] s = pd.Series([1, 2, np.nan, np.nan, 5]) msg = (r"Limit must be greater than 0|" "time-weighted interpolation only works on Series or" r" DataFrames with a DatetimeIndex|" - r"invalid method '(polynomial|spline|None)' to interpolate|" - "Limit must be an integer") + r"Limit must be an integer|" + r"You must specify the order of the spline") for limit in [-1, 0, 1., 2.]: for method in methods: with pytest.raises(ValueError, match=msg): s.interpolate(limit=limit, method=method) + def test_interp_invalid_method(self): + s = Series([1, 3, np.nan, 12, np.nan, 25]) + + invalid_methods = [None, 'nonexistent_method'] + for method in invalid_methods: + msg = "method must be one of.*\\. Got '{}' instead".format(method) + with pytest.raises(ValueError, match=msg): + s.interpolate(method=method) + # When an invalid method and invalid limit (such as -1) are + # provided, the error message reflects the invalid method. + with pytest.raises(ValueError, match=msg): + s.interpolate(method=method, limit=-1) + def test_interp_limit_forward(self): s = Series([1, 3, np.nan, np.nan, np.nan, 11]) @@ -1277,7 +1290,7 @@ def test_interp_limit_no_nans(self): @pytest.mark.parametrize("method", ['polynomial', 'spline']) def test_no_order(self, method): s = Series([0, 1, np.nan, 3]) - msg = "invalid method '{}' to interpolate".format(method) + msg = "You must specify the order of the spline or polynomial" with pytest.raises(ValueError, match=msg): s.interpolate(method=method) @@ -1315,10 +1328,10 @@ def test_spline_interpolation(self): @td.skip_if_no_scipy def test_spline_error(self): - # see gh-10633 + # see GH-10633, GH-24014 s = pd.Series(np.arange(10) ** 2) s[np.random.randint(0, 9, 3)] = np.nan - msg = "invalid method 'spline' to interpolate" + msg = "You must specify the order of the spline or polynomial" with pytest.raises(ValueError, match=msg): s.interpolate(method='spline') From 5bd3d4d6d5c796663b1cb1f99bdc9440ae6a085b Mon Sep 17 00:00:00 2001 From: Nicholas Musolino Date: Sat, 9 Feb 2019 13:08:56 -0500 Subject: [PATCH 02/11] Actually validate `order` before use in spline --- pandas/core/missing.py | 4 ++-- pandas/tests/series/test_missing.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pandas/core/missing.py b/pandas/core/missing.py index cc7bdf95200d1..98aac3d094b93 100644 --- a/pandas/core/missing.py +++ b/pandas/core/missing.py @@ -293,8 +293,8 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None, bounds_error=bounds_error) new_y = terp(new_x) elif method == 'spline': - # GH #10633 - if not order: + # GH #10633, #24014 + if order is None or not (0 < order): raise ValueError("order needs to be specified and greater than 0") terp = interpolate.UnivariateSpline(x, y, k=order, **kwargs) new_y = terp(new_x) diff --git a/pandas/tests/series/test_missing.py b/pandas/tests/series/test_missing.py index b12fed93c8cb6..ac2de38f95fa6 100644 --- a/pandas/tests/series/test_missing.py +++ b/pandas/tests/series/test_missing.py @@ -1336,8 +1336,9 @@ def test_spline_error(self): s.interpolate(method='spline') msg = "order needs to be specified and greater than 0" - with pytest.raises(ValueError, match=msg): - s.interpolate(method='spline', order=0) + for invalid_order in [-1, -1., 0, 0., np.nan]: + with pytest.raises(ValueError, match=msg): + s.interpolate(method='spline', order=invalid_order) def test_interp_timedelta64(self): # GH 6424 From c4ef8e9dcba041fe0c5bb5894261a06841a84271 Mon Sep 17 00:00:00 2001 From: Nicholas Musolino Date: Sat, 9 Feb 2019 18:50:45 -0500 Subject: [PATCH 03/11] Remove unnecessary check and dead code --- pandas/core/internals/blocks.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 47ee6dacdd001..4e2c04dba8b04 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -1118,18 +1118,15 @@ def check_int_bool(self, inplace): # validate the interp method m = missing.clean_interp_method(method, **kwargs) - if m is not None: - r = check_int_bool(self, inplace) - if r is not None: - return r - return self._interpolate(method=m, index=index, values=values, - axis=axis, limit=limit, - limit_direction=limit_direction, - limit_area=limit_area, - fill_value=fill_value, inplace=inplace, - downcast=downcast, **kwargs) - - raise ValueError("invalid method '{0}' to interpolate.".format(method)) + r = check_int_bool(self, inplace) + if r is not None: + return r + return self._interpolate(method=m, index=index, values=values, + axis=axis, limit=limit, + limit_direction=limit_direction, + limit_area=limit_area, + fill_value=fill_value, inplace=inplace, + downcast=downcast, **kwargs) def _interpolate_with_fill(self, method='pad', axis=0, inplace=False, limit=None, fill_value=None, coerce=False, From f6b890782b7deac0d99c319d89665d9db3139117 Mon Sep 17 00:00:00 2001 From: Nicholas Musolino Date: Sat, 9 Feb 2019 19:14:24 -0500 Subject: [PATCH 04/11] Clean up comparison/tests based on feedback --- pandas/core/missing.py | 2 +- pandas/tests/series/test_missing.py | 43 +++++++++++++---------------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/pandas/core/missing.py b/pandas/core/missing.py index 98aac3d094b93..2b3f7b42bf4a0 100644 --- a/pandas/core/missing.py +++ b/pandas/core/missing.py @@ -294,7 +294,7 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None, new_y = terp(new_x) elif method == 'spline': # GH #10633, #24014 - if order is None or not (0 < order): + if order is None or (order <= 0): raise ValueError("order needs to be specified and greater than 0") terp = interpolate.UnivariateSpline(x, y, k=order, **kwargs) new_y = terp(new_x) diff --git a/pandas/tests/series/test_missing.py b/pandas/tests/series/test_missing.py index ac2de38f95fa6..387f1f21e3b6a 100644 --- a/pandas/tests/series/test_missing.py +++ b/pandas/tests/series/test_missing.py @@ -1077,18 +1077,18 @@ def test_interp_limit(self): with pytest.raises(ValueError, match=msg): s.interpolate(limit=limit, method=method) - def test_interp_invalid_method(self): + @pytest.mark.parametrize("invalid_method", [None, 'nonexistent_method']) + def test_interp_invalid_method(self, invalid_method): s = Series([1, 3, np.nan, 12, np.nan, 25]) - invalid_methods = [None, 'nonexistent_method'] - for method in invalid_methods: - msg = "method must be one of.*\\. Got '{}' instead".format(method) - with pytest.raises(ValueError, match=msg): - s.interpolate(method=method) - # When an invalid method and invalid limit (such as -1) are - # provided, the error message reflects the invalid method. - with pytest.raises(ValueError, match=msg): - s.interpolate(method=method, limit=-1) + msg = "method must be one of.*\\. Got '{}' instead".format(invalid_method) + with pytest.raises(ValueError, match=msg): + s.interpolate(method=invalid_method) + + # When an invalid method and invalid limit (such as -1) are + # provided, the error message reflects the invalid method. + with pytest.raises(ValueError, match=msg): + s.interpolate(method=invalid_method, limit=-1) def test_interp_limit_forward(self): s = Series([1, 3, np.nan, np.nan, np.nan, 11]) @@ -1289,11 +1289,20 @@ def test_interp_limit_no_nans(self): @td.skip_if_no_scipy @pytest.mark.parametrize("method", ['polynomial', 'spline']) def test_no_order(self, method): + # see GH-10633, GH-24014 s = Series([0, 1, np.nan, 3]) msg = "You must specify the order of the spline or polynomial" with pytest.raises(ValueError, match=msg): s.interpolate(method=method) + @td.skip_if_no_scipy + @pytest.mark.parametrize('order', [-1, -1.0, 0, 0.0]) + def test_interpolate_spline_invalid_order(self, order): + s = Series([0, 1, np.nan, 3]) + msg = "order needs to be specified and greater than 0" + with pytest.raises(ValueError, match=msg): + s.interpolate(method='spline', order=order) + @td.skip_if_no_scipy def test_spline(self): s = Series([1, 2, np.nan, 4, 5, np.nan, 7]) @@ -1326,20 +1335,6 @@ def test_spline_interpolation(self): expected1 = s.interpolate(method='spline', order=1) assert_series_equal(result1, expected1) - @td.skip_if_no_scipy - def test_spline_error(self): - # see GH-10633, GH-24014 - s = pd.Series(np.arange(10) ** 2) - s[np.random.randint(0, 9, 3)] = np.nan - msg = "You must specify the order of the spline or polynomial" - with pytest.raises(ValueError, match=msg): - s.interpolate(method='spline') - - msg = "order needs to be specified and greater than 0" - for invalid_order in [-1, -1., 0, 0., np.nan]: - with pytest.raises(ValueError, match=msg): - s.interpolate(method='spline', order=invalid_order) - def test_interp_timedelta64(self): # GH 6424 df = Series([1, np.nan, 3], From c4f3b6df12d91bbacc15938423d03e69b867a3b7 Mon Sep 17 00:00:00 2001 From: Nicholas Musolino Date: Sat, 9 Feb 2019 19:20:58 -0500 Subject: [PATCH 05/11] Include invalid order value in exception --- pandas/core/missing.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/missing.py b/pandas/core/missing.py index 2b3f7b42bf4a0..3baf8249042e1 100644 --- a/pandas/core/missing.py +++ b/pandas/core/missing.py @@ -295,7 +295,8 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None, elif method == 'spline': # GH #10633, #24014 if order is None or (order <= 0): - raise ValueError("order needs to be specified and greater than 0") + raise ValueError("order needs to be specified and greater than 0; " + "got order: {}".format(order)) terp = interpolate.UnivariateSpline(x, y, k=order, **kwargs) new_y = terp(new_x) else: From 2d5ec0d96958020864a92a4d8dba7e21e498aa12 Mon Sep 17 00:00:00 2001 From: Nicholas Musolino Date: Sun, 10 Feb 2019 18:36:51 -0500 Subject: [PATCH 06/11] Check for NaN order in spline validation --- pandas/core/missing.py | 2 +- pandas/tests/series/test_missing.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/missing.py b/pandas/core/missing.py index 3baf8249042e1..9acdb1a06b2d1 100644 --- a/pandas/core/missing.py +++ b/pandas/core/missing.py @@ -294,7 +294,7 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None, new_y = terp(new_x) elif method == 'spline': # GH #10633, #24014 - if order is None or (order <= 0): + if isna(order) or (order <= 0): raise ValueError("order needs to be specified and greater than 0; " "got order: {}".format(order)) terp = interpolate.UnivariateSpline(x, y, k=order, **kwargs) diff --git a/pandas/tests/series/test_missing.py b/pandas/tests/series/test_missing.py index 387f1f21e3b6a..8c36f203acffb 100644 --- a/pandas/tests/series/test_missing.py +++ b/pandas/tests/series/test_missing.py @@ -1296,7 +1296,7 @@ def test_no_order(self, method): s.interpolate(method=method) @td.skip_if_no_scipy - @pytest.mark.parametrize('order', [-1, -1.0, 0, 0.0]) + @pytest.mark.parametrize('order', [-1, -1.0, 0, 0.0, np.nan]) def test_interpolate_spline_invalid_order(self, order): s = Series([0, 1, np.nan, 3]) msg = "order needs to be specified and greater than 0" From 097b9e4ca56dc390a713829cbdf7e9b8d1062c14 Mon Sep 17 00:00:00 2001 From: Nicholas Musolino Date: Sun, 10 Feb 2019 19:12:14 -0500 Subject: [PATCH 07/11] Add whatsnew entry for bug fix --- doc/source/whatsnew/v0.25.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 4032dc20b2e19..cd087c6429d6d 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -139,7 +139,7 @@ Indexing Missing ^^^^^^^ -- +- Fixed misleading exception message in :meth:`Series.missing` if argument ``order`` is required, but omitted (:issue:`10633`, :issue:`24014`). - - From becc36dbfb90a3a7cb646bf6a1f4f9000780358b Mon Sep 17 00:00:00 2001 From: Nicholas Musolino Date: Sun, 10 Feb 2019 19:54:44 -0500 Subject: [PATCH 08/11] CLN: Make unit tests assert one error at a time --- pandas/tests/series/test_missing.py | 37 ++++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/pandas/tests/series/test_missing.py b/pandas/tests/series/test_missing.py index 8c36f203acffb..934b4a1cf3f34 100644 --- a/pandas/tests/series/test_missing.py +++ b/pandas/tests/series/test_missing.py @@ -855,6 +855,13 @@ def test_series_pad_backfill_limit(self): class TestSeriesInterpolateData(): + # This list does not include method 'time'. That method requires a Series + # with a DatetimeIndex, and is tested separately below. + NONTEMPORAL_INTERPOLATE_METHODS = [ + 'linear', 'index', 'values', 'nearest', 'zero', 'slinear', + 'quadratic', 'cubic', 'barycentric', 'krogh', 'polynomial', 'spline', + 'piecewise_polynomial', 'from_derivatives', 'pchip', 'akima', + ] def test_interpolate(self, datetime_series, string_series): ts = Series(np.arange(len(datetime_series), dtype=float), @@ -1061,21 +1068,23 @@ def test_interp_limit(self): result = s.interpolate(method='linear', limit=2) assert_series_equal(result, expected) - # GH 9217, make sure limit is an int and greater than 0 - methods = ['linear', 'time', 'index', 'values', 'nearest', 'zero', - 'slinear', 'quadratic', 'cubic', 'barycentric', 'krogh', - 'polynomial', 'spline', 'piecewise_polynomial', - 'from_derivatives', 'pchip', 'akima'] + @pytest.mark.parametrize("method", NONTEMPORAL_INTERPOLATE_METHODS) + @pytest.mark.parametrize("limit", [-1, 0]) + def test_interpolate_invalid_nonpositive_limit(self, method, limit): + # GH 9217: make sure limit is greater than zero s = pd.Series([1, 2, np.nan, np.nan, 5]) - msg = (r"Limit must be greater than 0|" - "time-weighted interpolation only works on Series or" - r" DataFrames with a DatetimeIndex|" - r"Limit must be an integer|" - r"You must specify the order of the spline") - for limit in [-1, 0, 1., 2.]: - for method in methods: - with pytest.raises(ValueError, match=msg): - s.interpolate(limit=limit, method=method) + with pytest.raises(ValueError, match="Limit must be greater than 0"): + # Pass order=1 for 'spline' and 'polynomial'. + s.interpolate(limit=limit, method=method, order=1) + + @pytest.mark.parametrize("method", NONTEMPORAL_INTERPOLATE_METHODS) + def test_interpolate_invalid_float_limit(self, method): + # GH 9217: make sure limit is an integer. + s = pd.Series([1, 2, np.nan, np.nan, 5]) + limit = 2.0 + with pytest.raises(ValueError, match="Limit must be an integer"): + # Pass order=1 for 'spline' and 'polynomial'. + s.interpolate(limit=limit, method=method, order=1) @pytest.mark.parametrize("invalid_method", [None, 'nonexistent_method']) def test_interp_invalid_method(self, invalid_method): From 33a0de29ef8bad1ec8f66935de8916ef23bfed9b Mon Sep 17 00:00:00 2001 From: Nicholas Musolino Date: Sun, 10 Feb 2019 19:55:15 -0500 Subject: [PATCH 09/11] CLN: break test into distinct test case --- pandas/tests/series/test_missing.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pandas/tests/series/test_missing.py b/pandas/tests/series/test_missing.py index 934b4a1cf3f34..3e4db63ceeab3 100644 --- a/pandas/tests/series/test_missing.py +++ b/pandas/tests/series/test_missing.py @@ -882,12 +882,11 @@ def test_interpolate(self, datetime_series, string_series): time_interp = ord_ts_copy.interpolate(method='time') tm.assert_series_equal(time_interp, ord_ts) - # try time interpolation on a non-TimeSeries - # Only raises ValueError if there are NaNs. - non_ts = string_series.copy() - non_ts[0] = np.NaN - msg = ("time-weighted interpolation only works on Series or DataFrames" - " with a DatetimeIndex") + def test_interpolate_time_raises_for_non_timeseries(self): + # When method='time' is used on a non-TimeSeries that contains a null + # value, a ValueError should be raised. + non_ts = Series([0, 1, 2, np.NaN]) + msg = "time-weighted interpolation only works on Series.* with a DatetimeIndex" with pytest.raises(ValueError, match=msg): non_ts.interpolate(method='time') From 24cd9f5af9d78806d224adc3220ef8fa8be8abb9 Mon Sep 17 00:00:00 2001 From: Nicholas Musolino Date: Sun, 10 Feb 2019 20:00:48 -0500 Subject: [PATCH 10/11] PEP8 fix in test module --- pandas/tests/series/test_missing.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/tests/series/test_missing.py b/pandas/tests/series/test_missing.py index 3e4db63ceeab3..08b38f200c9fb 100644 --- a/pandas/tests/series/test_missing.py +++ b/pandas/tests/series/test_missing.py @@ -886,7 +886,8 @@ def test_interpolate_time_raises_for_non_timeseries(self): # When method='time' is used on a non-TimeSeries that contains a null # value, a ValueError should be raised. non_ts = Series([0, 1, 2, np.NaN]) - msg = "time-weighted interpolation only works on Series.* with a DatetimeIndex" + msg = ("time-weighted interpolation only works on Series.* " + "with a DatetimeIndex") with pytest.raises(ValueError, match=msg): non_ts.interpolate(method='time') @@ -1089,7 +1090,7 @@ def test_interpolate_invalid_float_limit(self, method): def test_interp_invalid_method(self, invalid_method): s = Series([1, 3, np.nan, 12, np.nan, 25]) - msg = "method must be one of.*\\. Got '{}' instead".format(invalid_method) + msg = "method must be one of.* Got '{}' instead".format(invalid_method) with pytest.raises(ValueError, match=msg): s.interpolate(method=invalid_method) From 69dd362aff411f2824a7dc8ae5681177dde96bb9 Mon Sep 17 00:00:00 2001 From: Nicholas Musolino Date: Mon, 11 Feb 2019 07:35:49 -0500 Subject: [PATCH 11/11] CLN: Test fixture for interpolate methods --- pandas/tests/series/test_missing.py | 45 +++++++++++++++++------------ 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/pandas/tests/series/test_missing.py b/pandas/tests/series/test_missing.py index 08b38f200c9fb..f07dd1dfb5fda 100644 --- a/pandas/tests/series/test_missing.py +++ b/pandas/tests/series/test_missing.py @@ -854,15 +854,23 @@ def test_series_pad_backfill_limit(self): assert_series_equal(result, expected) -class TestSeriesInterpolateData(): - # This list does not include method 'time'. That method requires a Series - # with a DatetimeIndex, and is tested separately below. - NONTEMPORAL_INTERPOLATE_METHODS = [ - 'linear', 'index', 'values', 'nearest', 'zero', 'slinear', - 'quadratic', 'cubic', 'barycentric', 'krogh', 'polynomial', 'spline', - 'piecewise_polynomial', 'from_derivatives', 'pchip', 'akima', - ] +@pytest.fixture(params=['linear', 'index', 'values', 'nearest', 'slinear', + 'zero', 'quadratic', 'cubic', 'barycentric', 'krogh', + 'polynomial', 'spline', 'piecewise_polynomial', + 'from_derivatives', 'pchip', 'akima', ]) +def nontemporal_method(request): + """ Fixture that returns an (method name, required kwargs) pair. + + This fixture does not include method 'time' as a parameterization; that + method requires a Series with a DatetimeIndex, and is generally tested + separately from these non-temporal methods. + """ + method = request.param + kwargs = dict(order=1) if method in ('spline', 'polynomial') else dict() + return method, kwargs + +class TestSeriesInterpolateData(): def test_interpolate(self, datetime_series, string_series): ts = Series(np.arange(len(datetime_series), dtype=float), datetime_series.index) @@ -1068,23 +1076,22 @@ def test_interp_limit(self): result = s.interpolate(method='linear', limit=2) assert_series_equal(result, expected) - @pytest.mark.parametrize("method", NONTEMPORAL_INTERPOLATE_METHODS) @pytest.mark.parametrize("limit", [-1, 0]) - def test_interpolate_invalid_nonpositive_limit(self, method, limit): - # GH 9217: make sure limit is greater than zero - s = pd.Series([1, 2, np.nan, np.nan, 5]) + def test_interpolate_invalid_nonpositive_limit(self, nontemporal_method, + limit): + # GH 9217: make sure limit is greater than zero. + s = pd.Series([1, 2, np.nan, 4]) + method, kwargs = nontemporal_method with pytest.raises(ValueError, match="Limit must be greater than 0"): - # Pass order=1 for 'spline' and 'polynomial'. - s.interpolate(limit=limit, method=method, order=1) + s.interpolate(limit=limit, method=method, **kwargs) - @pytest.mark.parametrize("method", NONTEMPORAL_INTERPOLATE_METHODS) - def test_interpolate_invalid_float_limit(self, method): + def test_interpolate_invalid_float_limit(self, nontemporal_method): # GH 9217: make sure limit is an integer. - s = pd.Series([1, 2, np.nan, np.nan, 5]) + s = pd.Series([1, 2, np.nan, 4]) + method, kwargs = nontemporal_method limit = 2.0 with pytest.raises(ValueError, match="Limit must be an integer"): - # Pass order=1 for 'spline' and 'polynomial'. - s.interpolate(limit=limit, method=method, order=1) + s.interpolate(limit=limit, method=method, **kwargs) @pytest.mark.parametrize("invalid_method", [None, 'nonexistent_method']) def test_interp_invalid_method(self, invalid_method):