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 | |
parent | b97663c8b33bbce12926887bf6ddac68fbadb42d (diff) | |
download | numpy-8b1e2f929fdfb79e0a446a1fb7bec33a799d492b.tar.gz |
Add a few more docstrings using add_docstring.
-rw-r--r-- | COMPATIBILITY | 17 | ||||
-rw-r--r-- | DEV_README.txt | 15 | ||||
-rw-r--r-- | numpy/__init__.py | 2 | ||||
-rw-r--r-- | numpy/add_newdocs.py | 16 | ||||
-rw-r--r-- | numpy/lib/function_base.py | 19 | ||||
-rw-r--r-- | numpy/lib/src/_compiled_base.c | 7 |
6 files changed, 68 insertions, 8 deletions
diff --git a/COMPATIBILITY b/COMPATIBILITY index b9cc937d2..b9d46cfae 100644 --- a/COMPATIBILITY +++ b/COMPATIBILITY @@ -1,6 +1,7 @@ -X.flat returns an indexable 1-D iterator (mostly similar to an array but always 1-d) +X.flat returns an indexable 1-D iterator (mostly similar to an array +but always 1-d) --- only has .copy and .__array__ attributes of an array!!! .typecode() --> .dtypechar @@ -10,6 +11,8 @@ X.flat returns an indexable 1-D iterator (mostly similar to an array but always .itemsize() -> .itemsize +.toscalar() -> .item() + If you used typecode characters: 'c' -> 'S1' @@ -22,11 +25,12 @@ If you used typecode characters: C -level -some API calls that used to take PyObject * now take PyArrayObject * (this should only cause warnings during compile and not actual problems). +some API calls that used to take PyObject * now take PyArrayObject * +(this should only cause warnings during compile and not actual problems). PyArray_Take These commands now return a buffer that must be freed once it is used -using PyMemData_FREE(ptr) or PyMemData_XFREE(ptr); +using PyMemData_FREE(ptr); a->descr->zero --> PyArray_Zero(a) a->descr->one --> PyArray_One(a) @@ -36,7 +40,8 @@ Numeric/arrayobject.h --> numpy/arrayobject.h # These will actually work and are defines for PyArray_BYTE, # but you really should change it in your code -PyArray_CHAR --> PyArray_BYTE (or PyArray_STRING which is more flexible) +PyArray_CHAR --> PyArray_BYTE + (or PyArray_STRING which is more flexible) PyArray_SBYTE --> PyArray_BYTE Any uses of character codes will need adjusting.... @@ -44,8 +49,8 @@ use PyArray_XXXLTR where XXX is the name of the type. If you used function pointers directly (why did you do that?), -the arguments have changed. Everything that was an int is now an intp. Also, -arrayobjects should be passed in at the end. +the arguments have changed. Everything that was an int is now an intp. +Also, arrayobjects should be passed in at the end. a->descr->cast[i](fromdata, fromstep, todata, tostep, n) a->descr->cast[i](fromdata, todata, n, PyArrayObject *in, PyArrayObject *out) diff --git a/DEV_README.txt b/DEV_README.txt new file mode 100644 index 000000000..6f89b5d5b --- /dev/null +++ b/DEV_README.txt @@ -0,0 +1,15 @@ + +Thank you for your willingness to help make NumPy the best array system +available. + +The only rules we like to follow are to try hard to keep the SVN +repository in a buildable state and to not indiscriminately muck with +others' code. + +Simple changes and obvious improvements are always welcome. Changes +that fundamentally change behavior need discussion on scipy-dev@scipy.org +before anything is done. + +Please add meaningful comments when you check changes in. These comments +form the basis of the change-log. + diff --git a/numpy/__init__.py b/numpy/__init__.py index 466461dbc..706959e90 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -42,4 +42,6 @@ else: test = ScipyTest('numpy').test + import add_newdocs + # TODO: Fix __doc__ diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py new file mode 100644 index 000000000..156f4f698 --- /dev/null +++ b/numpy/add_newdocs.py @@ -0,0 +1,16 @@ + +from lib import add_newdoc + +add_newdoc('numpy.core','dtypedescr', + [('fields', "Fields of the data-typedescr if any."), + ('alignment', "Needed alignment for this data-type"), + ('byteorder', + "Little-endian (<), big-endian (>), native (=), or "\ + "not-applicable (|)"), + ('char', "Letter typecode for this descriptor"), + ('dtype', "Typeobject associated with this descriptor"), + ('kind', "Character giving type-family of this descriptor"), + ('itemsize', "Size of each item"), + ('num', "Internally-used number for builtin base") + ] + ) 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; } |