summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchris.burns <chris.burns@localhost>2007-12-15 23:27:14 +0000
committerchris.burns <chris.burns@localhost>2007-12-15 23:27:14 +0000
commit22fbdc5c744674550be074550862645ddf423b31 (patch)
tree30fcc217bd8420d64ccda7e243c0838e2af5e3ff
parent94e351cbda3fb151af4ae18d6ebfc9b409e27022 (diff)
downloadnumpy-22fbdc5c744674550be074550862645ddf423b31.tar.gz
Added docstrings to deprecate funcs
-rw-r--r--utils.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/utils.py b/utils.py
index edde2d168..ab5220c01 100644
--- a/utils.py
+++ b/utils.py
@@ -84,6 +84,15 @@ else:
return func
def deprecate(func, oldname=None, newname=None):
+ """Deprecate old functions.
+ Issues a DeprecationWarning, adds warning to oldname's docstring,
+ rebinds oldname.__name__ and returns new function object.
+
+ Example:
+ oldfunc = deprecate(newfunc, 'oldfunc', 'newfunc')
+
+ """
+
import warnings
if oldname is None:
oldname = func.func_name
@@ -113,6 +122,17 @@ def deprecate(func, oldname=None, newname=None):
return newfunc
def deprecate_with_doc(somestr):
+ """Decorator to deprecate functions and provide detailed documentation
+ with 'somestr' that is added to the functions docstring.
+
+ Example:
+ depmsg = 'function numpy.lib.foo has been merged into numpy.lib.io.foobar'
+ @deprecate_with_doc(depmsg)
+ def foo():
+ pass
+
+ """
+
def _decorator(func):
newfunc = deprecate(func)
newfunc.__doc__ += "\n" + somestr