[Numpy-svn] r3096 - in trunk/numpy: . core/src

numpy-svn at scipy.org numpy-svn at scipy.org
Tue Aug 29 12:20:31 CDT 2006


Author: charris
Date: 2006-08-29 12:20:29 -0500 (Tue, 29 Aug 2006)
New Revision: 3096

Modified:
   trunk/numpy/add_newdocs.py
   trunk/numpy/core/src/arraymethods.c
Log:
Finish moving comments from arraymethods to add_newdocs.
Replace hardcoded 1 by METH_VARARGS in arraymethods.


Modified: trunk/numpy/add_newdocs.py
===================================================================
--- trunk/numpy/add_newdocs.py	2006-08-29 17:15:31 UTC (rev 3095)
+++ trunk/numpy/add_newdocs.py	2006-08-29 17:20:29 UTC (rev 3096)
@@ -448,6 +448,22 @@
 ##############################################################################
 
 
+add_newdoc('numpy.core.multiarray', 'ndarray', ('__array__',
+""" a.__array__(|dtype) -> reference if type unchanged, copy otherwise.
+
+Returns either a new reference to self if dtype is not given or a new array
+of provided data type if dtype is different from the current dtype of the
+array.
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('__array_wrap__',
+"""a.__array_wrap__(obj) -> Object of same type as a from ndarray obj.
+
+"""))
+
+
 add_newdoc('numpy.core.multiarray', 'ndarray', ('__copy__',
 """a.__copy__(|order) -> copy, possibly with different order.
 
@@ -471,6 +487,29 @@
 """))
 
 
+add_newdoc('numpy.core.multiarray', 'ndarray', ('__reduce__',
+"""a.__reduce__()
+
+For pickling.
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('__setstate__',
+"""a.__setstate__(version, shape, typecode, isfortran, rawdata)
+
+For unpickling.
+
+Arguments:
+    version -- optional pickle version. If omitted defaults to 0.
+    shape -- a tuple giving the shape
+    typecode -- a typecode
+    isFortran --  a bool stating if Fortran or no
+    rawdata -- a binary string with the data (or a list if Object array)
+
+"""))
+
+
 add_newdoc('numpy.core.multiarray', 'ndarray', ('all',
 """ a.all(axis=None)
 
@@ -569,16 +608,19 @@
 
 add_newdoc('numpy.core.multiarray', 'ndarray', ('compress',
 """a.compress(condition=, axis=None, out=None)
+
 """))
 
 
 add_newdoc('numpy.core.multiarray', 'ndarray', ('conj',
 """a.conj()
+
 """))
 
 
 add_newdoc('numpy.core.multiarray', 'ndarray', ('conjugate',
 """a.conjugate()
+
 """))
 
 
@@ -611,9 +653,25 @@
 
 add_newdoc('numpy.core.multiarray', 'ndarray', ('diagonal',
 """a.diagonal(offset=0, axis1=0, axis2=1)
+
 """))
 
 
+add_newdoc('numpy.core.multiarray', 'ndarray', ('dump',
+"""a.dump(file) Dump to specified file.
+
+Arguments:
+    file -- string naming the dump file.
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('dumps',
+"""a.dumps() -> string containing the dump?
+
+"""))
+
+
 add_newdoc('numpy.core.multiarray', 'ndarray', ('fill',
 """a.fill(value) -> None. Fill the array with the scalar value.
 """))

Modified: trunk/numpy/core/src/arraymethods.c
===================================================================
--- trunk/numpy/core/src/arraymethods.c	2006-08-29 17:15:31 UTC (rev 3095)
+++ trunk/numpy/core/src/arraymethods.c	2006-08-29 17:20:29 UTC (rev 3096)
@@ -481,8 +481,6 @@
 
 /* default sub-type implementation */
 
-static char doc_wraparray[] = "m.__array_wrap__(obj) returns an object of "\
-	"type m from the ndarray object obj";
 
 static PyObject *
 array_wraparray(PyArrayObject *self, PyObject *args)
@@ -516,8 +514,6 @@
 }
 
 
-static char doc_array_getarray[] = "m.__array__(|dtype) just returns either a new reference to self if dtype is not given or a new array of provided data type if dtype is different from the current dtype of the array.";
-
 static PyObject *
 array_getarray(PyArrayObject *self, PyObject *args)
 {
@@ -811,7 +807,6 @@
 	return 0;
 }
 
-static char doc_reduce[] = "a.__reduce__()  for pickling.";
 
 static PyObject *
 array_reduce(PyArrayObject *self, PyObject *args)
@@ -886,14 +881,7 @@
 	return ret;
 }
 
-static char doc_setstate[] = "a.__setstate__(tuple) for unpickling.";
 
-/*
-	   1) a Tuple giving the shape
-	   2) a PyArray_Descr Object
-	   3) a Bool stating if Fortran or not
-	   4) a binary string with the data (or a list if Object array)
-*/
 
 static size_t _array_fill_strides(intp *, intp *, int, size_t, int, int *);
 
@@ -1108,8 +1096,6 @@
 }
 
 
-static char doc_dump[] = "m.dump(file)";
-
 static PyObject *
 array_dump(PyArrayObject *self, PyObject *args)
 {
@@ -1124,7 +1110,6 @@
 	return Py_None;
 }
 
-static char doc_dumps[] = "m.dumps()";
 
 static PyObject *
 array_dumps(PyArrayObject *self, PyObject *args)
@@ -1539,50 +1524,30 @@
 }
 
 static PyMethodDef array_methods[] = {
-        {"astype", (PyCFunction)array_cast,
-            1, NULL},
-        {"byteswap", (PyCFunction)array_byteswap,
-            1, NULL},
-        {"copy", (PyCFunction)array_copy,
-            1, NULL},
-	{"getfield", (PyCFunction)array_getfield,
-            METH_VARARGS | METH_KEYWORDS, NULL},
-        {"item", (PyCFunction)array_toscalar,
-            METH_VARARGS, NULL},
-	{"tofile", (PyCFunction)array_tofile,
-            METH_VARARGS | METH_KEYWORDS, NULL},
-        {"tolist", (PyCFunction)array_tolist,
-            1, NULL},
-        {"tostring", (PyCFunction)array_tostring,
-            METH_VARARGS | METH_KEYWORDS, NULL},
-        {"resize", (PyCFunction)array_resize,
-            METH_VARARGS | METH_KEYWORDS, NULL},
-	{"setfield", (PyCFunction)array_setfield,
-            METH_VARARGS | METH_KEYWORDS, NULL},
 
 	/* for subtypes */
 	{"__array__", (PyCFunction)array_getarray,
-            1, doc_array_getarray},
+            METH_VARARGS, NULL},
 	{"__array_wrap__", (PyCFunction)array_wraparray,
-            1, doc_wraparray},
+            METH_VARARGS, NULL},
 
 	/* for the copy module */
         {"__copy__", (PyCFunction)array_copy,
-            1, NULL},
+            METH_VARARGS, NULL},
         {"__deepcopy__", (PyCFunction)array_deepcopy,
-            1, NULL},
+            METH_VARARGS, NULL},
 
         /* for Pickling */
         {"__reduce__", (PyCFunction) array_reduce,
-            1, doc_reduce},
+            METH_VARARGS, NULL},
 	{"__setstate__", (PyCFunction) array_setstate,
-            1, doc_setstate},
+            METH_VARARGS, NULL},
 	{"dumps", (PyCFunction) array_dumps,
-            1, doc_dumps},
+            METH_VARARGS, NULL},
 	{"dump", (PyCFunction) array_dump,
-            1, doc_dump},
+            METH_VARARGS, NULL},
 
-	/* Extended methods added 2005 */
+	/* Original and Extended methods added 2005 */
         {"all", (PyCFunction)array_all,
 	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"any", (PyCFunction)array_any,
@@ -1593,6 +1558,10 @@
 	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"argsort", (PyCFunction)array_argsort,
 	    METH_VARARGS|METH_KEYWORDS, NULL},
+        {"astype", (PyCFunction)array_cast,
+            METH_VARARGS, NULL},
+        {"byteswap", (PyCFunction)array_byteswap,
+            METH_VARARGS, NULL},
 	{"choose", (PyCFunction)array_choose,
 	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"clip", (PyCFunction)array_clip,
@@ -1603,6 +1572,8 @@
 	    METH_VARARGS, NULL},
 	{"conjugate", (PyCFunction)array_conjugate,
 	    METH_VARARGS, NULL},
+        {"copy", (PyCFunction)array_copy,
+            METH_VARARGS, NULL},
 	{"cumprod", (PyCFunction)array_cumprod,
 	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"cumsum", (PyCFunction)array_cumsum,
@@ -1613,6 +1584,10 @@
 	    METH_VARARGS, NULL},
 	{"flatten", (PyCFunction)array_flatten,
 	    METH_VARARGS, NULL},
+	{"getfield", (PyCFunction)array_getfield,
+            METH_VARARGS | METH_KEYWORDS, NULL},
+        {"item", (PyCFunction)array_toscalar,
+            METH_VARARGS, NULL},
 	{"max", (PyCFunction)array_max,
 	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"mean", (PyCFunction)array_mean,
@@ -1637,10 +1612,14 @@
 	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"reshape", (PyCFunction)array_reshape,
 	    METH_VARARGS|METH_KEYWORDS, NULL},
+        {"resize", (PyCFunction)array_resize,
+            METH_VARARGS | METH_KEYWORDS, NULL},
 	{"round", (PyCFunction)array_round,
 	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"searchsorted", (PyCFunction)array_searchsorted,
 	    METH_VARARGS, NULL},
+	{"setfield", (PyCFunction)array_setfield,
+            METH_VARARGS | METH_KEYWORDS, NULL},
 	{"setflags", (PyCFunction)array_setflags,
 	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"sort", (PyCFunction)array_sort,
@@ -1655,6 +1634,12 @@
 	    METH_VARARGS, NULL},
 	{"take", (PyCFunction)array_take,
 	    METH_VARARGS|METH_KEYWORDS, NULL},
+	{"tofile", (PyCFunction)array_tofile,
+            METH_VARARGS | METH_KEYWORDS, NULL},
+        {"tolist", (PyCFunction)array_tolist,
+            METH_VARARGS, NULL},
+        {"tostring", (PyCFunction)array_tostring,
+            METH_VARARGS | METH_KEYWORDS, NULL},
 	{"trace", (PyCFunction)array_trace,
 	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"transpose", (PyCFunction)array_transpose,



More information about the Numpy-svn mailing list