Skip to content

Remove 'out' from docstrings for wrapped numpy unary functions #2117

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

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 15 additions & 1 deletion xarray/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,22 @@ def func(self, *args, **kwargs):
def _method_wrapper(name):
def func(self, *args, **kwargs):
return _call_possibly_missing_method(self, name, args, kwargs)

def format_docstring(doc):
'''Unlike numpy we don't support the out kwarg.
Remove it from the docstring'''

if doc.find('out=None') != -1:
idx = doc.find('for full documentation.')
doc = ((doc[:idx] +
'for full documentation.\n\n' +
' The out keyword argument is not supported.' +
doc[idx + 23:]).replace(', out=None', ''))

return doc

func.__name__ = name
func.__doc__ = getattr(np.ndarray, name).__doc__
func.__doc__ = format_docstring(getattr(np.ndarray, name).__doc__)
return func


Expand Down