Skip to content
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

BUG: Fix exceptions when Series.interpolate's `order` parameter is missing or invalid #25246

Merged

Remove unnecessary check and dead code

  • Loading branch information...
nmusolino committed Feb 9, 2019
commit c4ef8e9dcba041fe0c5bb5894261a06841a84271
@@ -1118,18 +1118,15 @@ def check_int_bool(self, inplace):
# validate the interp method
m = missing.clean_interp_method(method, **kwargs)

This conversation was marked as resolved by gfyoung

This comment has been minimized.

Copy link
@nmusolino

nmusolino Feb 9, 2019

Author Contributor

I believe the check if m is not None on the following line (1121) and the subsequent raise on line 1132 are now unnecessary, and can be removed. I'd appreciate any second opinions on that.

This comment has been minimized.

Copy link
@gfyoung

gfyoung Feb 9, 2019

Member

I'm all for removing it, so long as we are sure that we can't get None ever returned for m.

This comment has been minimized.

Copy link
@nmusolino

nmusolino Feb 9, 2019

Author Contributor

Great. missing.clean_interp_method will not return None; if its method argument is None, it will raise (line 105 of missing.py below):

def clean_interp_method(method, **kwargs):
order = kwargs.get('order')
valid = ['linear', 'time', 'index', 'values', 'nearest', 'zero', 'slinear',
'quadratic', 'cubic', 'barycentric', 'polynomial', 'krogh',
'piecewise_polynomial', 'pchip', 'akima', 'spline',
'from_derivatives']
if method in ('spline', 'polynomial') and order is None:
raise ValueError("You must specify the order of the spline or "
"polynomial.")
if method not in valid:
raise ValueError("method must be one of {valid}. Got '{method}' "
"instead.".format(valid=valid, method=method))
return method

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,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.