diff options
| author | Travis Oliphant <oliphant@enthought.com> | 2006-01-05 10:28:41 +0000 |
|---|---|---|
| committer | Travis Oliphant <oliphant@enthought.com> | 2006-01-05 10:28:41 +0000 |
| commit | 8b1e2f929fdfb79e0a446a1fb7bec33a799d492b (patch) | |
| tree | 588d1fb59f52798ef54a98dbe5ef20210dd16eae /numpy/lib | |
| parent | b97663c8b33bbce12926887bf6ddac68fbadb42d (diff) | |
| download | numpy-8b1e2f929fdfb79e0a446a1fb7bec33a799d492b.tar.gz | |
Add a few more docstrings using add_docstring.
Diffstat (limited to 'numpy/lib')
| -rw-r--r-- | numpy/lib/function_base.py | 19 | ||||
| -rw-r--r-- | numpy/lib/src/_compiled_base.c | 7 |
2 files changed, 24 insertions, 2 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index d1166d2c7..d0b3535d0 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -7,7 +7,7 @@ l__all__ = ['logspace', 'linspace', 'nanargmin', 'nanmin', 'vectorize', 'asarray_chkfinite', 'average', 'histogram', 'bincount', 'digitize', 'cov', 'corrcoef', 'msort', 'median', 'sinc', 'hamming', 'hanning', 'bartlett', 'blackman', - 'kaiser', 'trapz', 'i0' + 'kaiser', 'trapz', 'i0', 'add_newdoc', 'add_docstring', ] import types @@ -24,7 +24,7 @@ from numpy.core.oldnumeric import ravel, nonzero, choose, \ from type_check import ScalarType from shape_base import atleast_1d from twodim_base import diag -from _compiled_base import digitize, bincount, _insert +from _compiled_base import digitize, bincount, _insert, add_docstring #end Fernando's utilities @@ -829,3 +829,18 @@ def trapz(y, x=None, dx=1.0, axis=-1): slice1[axis] = slice(1,None) slice2[axis] = slice(None,-1) return add.reduce(d * (y[slice1]+y[slice2])/2.0,axis) + +#always succeed +def add_newdoc(place, obj, doc): + try: + new = {} + exec 'from %s import %s' % (place, obj) in new + if isinstance(doc, str): + add_docstring(new[obj], doc.strip()) + elif isinstance(doc, tuple): + add_docstring(getattr(new[obj], doc[0]), doc[1].strip()) + elif isinstance(doc, list): + for val in doc: + add_docstring(getattr(new[obj], val[0]), val[1].strip()) + except: + pass diff --git a/numpy/lib/src/_compiled_base.c b/numpy/lib/src/_compiled_base.c index 063631c7e..e54c3c6d8 100644 --- a/numpy/lib/src/_compiled_base.c +++ b/numpy/lib/src/_compiled_base.c @@ -339,6 +339,7 @@ arr_insert(PyObject *self, PyObject *args, PyObject *kwdict) static PyTypeObject *PyMemberDescr_TypePtr=NULL; static PyTypeObject *PyGetSetDescr_TypePtr=NULL; +static PyTypeObject *PyMethodDescr_TypePtr=NULL; /* Can only be called if doc is currently NULL */ @@ -377,6 +378,9 @@ arr_add_docstring(PyObject *dummy, PyObject *args) _ADDDOC(MemberDescr, new->d_member->doc, new->d_member->name) else if _TESTDOC2(GetSetDescr) _ADDDOC(GetSetDescr, new->d_getset->doc, new->d_getset->name) + else if _TESTDOC2(MethodDescr) + _ADDDOC(MethodDescr, new->d_method->ml_doc, + new->d_method->ml_name) else { PyErr_SetString(PyExc_TypeError, "Cannot set a docstring for that object"); @@ -418,6 +422,9 @@ define_types(void) myobj = PyDict_GetItemString(tp_dict, "alignment"); if (myobj == NULL) return; PyMemberDescr_TypePtr = myobj->ob_type; + myobj = PyDict_GetItemString(tp_dict, "newbyteorder"); + if (myobj == NULL) return; + PyMethodDescr_TypePtr = myobj->ob_type; return; } |
