diff options
author | Chris Jordan-Squire <cjordan1@uw.edu> | 2011-08-05 10:43:51 -0500 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-08-29 20:19:04 -0600 |
commit | 180750b9a4a4dc46be32ed6d738329b2ab97abfa (patch) | |
tree | 331bb2eb603587c694ba50ae7d431eb2678bf274 /numpy/add_newdocs.py | |
parent | d91521e5fd858726998146e6055f677cc3aeb011 (diff) | |
download | numpy-180750b9a4a4dc46be32ed6d738329b2ab97abfa.tar.gz |
ENH: Add function for adding docstrings to ufuncs.
Diffstat (limited to 'numpy/add_newdocs.py')
-rw-r--r-- | numpy/add_newdocs.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index ce61c5f0e..f1ce48b69 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -5071,7 +5071,7 @@ add_newdoc('numpy.lib._compiled_base', 'unravel_index', add_newdoc('numpy.lib._compiled_base', 'add_docstring', """ - docstring(obj, docstring) + add_docstring(obj, docstring) Add a docstring to a built-in obj if possible. If the obj already has a docstring raise a RuntimeError @@ -5079,6 +5079,33 @@ add_newdoc('numpy.lib._compiled_base', 'add_docstring', raise a TypeError """) +add_newdoc('numpy.lib._compiled_base', 'add_newdoc_ufunc', + """ + add_ufunc_docstring(ufunc, new_docstring) + + Replace the docstring for a ufunc with new_docstring. + This method will only work if the current docstring for + the ufunc is NULL. (At the C level, i.e. when ufunc->doc is NULL.) + + Parameters + ---------- + ufunc : numpy.ufunc + A ufunc whose current doc is NULL. + new_docstring : string + The new docstring for the ufunc. + + Notes + ----- + + This method allocates memory for new_docstring on + the heap. Technically this creates a mempory leak, since this + memory will not be reclaimed until the end of the program + even if the ufunc itself is removed. However this will only + be a problem if the user is repeatedly creating ufuncs with + no documentation, adding documentation via add_newdoc_ufunc, + and then throwing away the ufunc. + """) + add_newdoc('numpy.lib._compiled_base', 'packbits', """ packbits(myarray, axis=None) |