summaryrefslogtreecommitdiff
path: root/numpy/lib/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/utils.py')
-rw-r--r--numpy/lib/utils.py42
1 files changed, 33 insertions, 9 deletions
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index d511c2a40..24252c834 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -193,7 +193,32 @@ def deprecate(*args, **kwargs):
else:
return _Deprecate(*args, **kwargs)
-deprecate_with_doc = lambda msg: _Deprecate(message=msg)
+
+def deprecate_with_doc(msg):
+ """
+ Deprecates a function and includes the deprecation in its docstring.
+
+ This function is used as a decorator. It returns an object that can be
+ used to issue a DeprecationWarning, by passing the to-be decorated
+ function as argument, this adds warning to the to-be decorated function's
+ docstring and returns the new function object.
+
+ See Also
+ --------
+ deprecate : Decorate a function such that it issues a `DeprecationWarning`
+
+ Parameters
+ ----------
+ msg : str
+ Additional explanation of the deprecation. Displayed in the
+ docstring after the warning.
+
+ Returns
+ -------
+ obj : object
+
+ """
+ return _Deprecate(message=msg)
#--------------------------------------------
@@ -587,11 +612,11 @@ def info(object=None, maxwidth=76, output=sys.stdout, toplevel='numpy'):
print(inspect.getdoc(object), file=output)
methods = pydoc.allmethods(object)
- if methods != []:
+
+ public_methods = [meth for meth in methods if meth[0] != '_']
+ if public_methods:
print("\n\nMethods:\n", file=output)
- for meth in methods:
- if meth[0] == '_':
- continue
+ for meth in public_methods:
thisobj = getattr(object, meth, None)
if thisobj is not None:
methstr, other = pydoc.splitdoc(
@@ -990,8 +1015,8 @@ def _median_nancheck(data, result, axis, out):
Input data to median function
result : Array or MaskedArray
Result of median function
- axis : {int, sequence of int, None}, optional
- Axis or axes along which the median was computed.
+ axis : int
+ Axis along which the median was computed.
out : ndarray, optional
Output array in which to place the result.
Returns
@@ -1001,8 +1026,7 @@ def _median_nancheck(data, result, axis, out):
"""
if data.size == 0:
return result
- data = np.moveaxis(data, axis, -1)
- n = np.isnan(data[..., -1])
+ n = np.isnan(data.take(-1, axis=axis))
# masked NaN values are ok
if np.ma.isMaskedArray(n):
n = n.filled(False)