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

DOC/DEPR: ensure that @deprecated functions have correct docstring #18215

Merged
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
4 changes: 2 additions & 2 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,13 +1361,13 @@ def idxmax(self, axis=None, skipna=True, *args, **kwargs):

# ndarray compat
argmin = deprecate('argmin', idxmin,
msg="'argmin' is deprecated. Use 'idxmin' instead. "
msg="'argmin' is deprecated, use 'idxmin' instead. "
"The behavior of 'argmin' will be corrected to "
"return the positional minimum in the future. "
"Use 'series.values.argmin' to get the position of "
"the minimum now.")
argmax = deprecate('argmax', idxmax,
msg="'argmax' is deprecated. Use 'idxmax' instead. "
msg="'argmax' is deprecated, use 'idxmax' instead. "
"The behavior of 'argmax' will be corrected to "
"return the positional maximum in the future. "
"Use 'series.values.argmax' to get the position of "
Expand Down
9 changes: 7 additions & 2 deletions pandas/util/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import inspect
import types
import warnings
from textwrap import dedent
from textwrap import dedent, wrap
from functools import wraps, update_wrapper


Expand All @@ -29,11 +29,16 @@ def deprecate(name, alternative, alt_name=None, klass=None,

alt_name = alt_name or alternative.__name__
klass = klass or FutureWarning
msg = msg or "{} is deprecated. Use {} instead".format(name, alt_name)
msg = msg or "{} is deprecated, use {} instead".format(name, alt_name)

@wraps(alternative)
def wrapper(*args, **kwargs):
warnings.warn(msg, klass, stacklevel=stacklevel)
return alternative(*args, **kwargs)

if getattr(wrapper, '__doc__', None) is not None:
wrapper.__doc__ = ('\n'.join(wrap(msg, 70)) + '\n'
+ dedent(wrapper.__doc__))
return wrapper


Expand Down