Skip to content

Commit

Permalink
DOC/DEPR: ensure that @deprecated functions have correct docstring (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche authored Nov 14, 2017
1 parent 69472f9 commit 22fcf43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

2 comments on commit 22fcf43

@gfyoung
Copy link
Member

@gfyoung gfyoung commented on 22fcf43 Nov 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jorisvandenbossche : GitHub seems to have been too helpful in rendering your "at-deprecated" commit message to reference some random user on the platform 😄

@jorisvandenbossche
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

His/her fault in taking such a name! :-)

Please sign in to comment.