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

numpy-svn at scipy.org numpy-svn at scipy.org
Tue Aug 29 01:02:17 CDT 2006


Author: charris
Date: 2006-08-29 01:02:10 -0500 (Tue, 29 Aug 2006)
New Revision: 3091

Modified:
   trunk/numpy/add_newdocs.py
   trunk/numpy/core/src/arraymethods.c
Log:
Move more documentation from arraymethods to add_newdocs.


Modified: trunk/numpy/add_newdocs.py
===================================================================
--- trunk/numpy/add_newdocs.py	2006-08-29 02:47:39 UTC (rev 3090)
+++ trunk/numpy/add_newdocs.py	2006-08-29 06:02:10 UTC (rev 3091)
@@ -447,6 +447,30 @@
 #
 ##############################################################################
 
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('__copy__',
+"""a.__copy__(|order) -> copy, possibly with different order.
+
+Return a copy of the array.
+
+Argument:
+    order -- Order of returned copy (default 'C')
+	If order is 'C' (False) then the result is contiguous (default).
+	If order is 'Fortran' (True) then the result has fortran order.
+	If order is 'Any' (None) then the result has fortran order
+	only if m is already in fortran order.;
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('__deepcopy__',
+"""a.__deepcopy__() -> Deep copy of array.
+
+Used if copy.deepcopy is called on an array.
+
+"""))
+
+
 add_newdoc('numpy.core.multiarray', 'ndarray', ('all',
 """ a.all(axis=None)
 
@@ -506,6 +530,24 @@
 """))
 
 
+add_newdoc('numpy.core.multiarray', 'ndarray', ('astype',
+"""a.astype(t) -> Copy of array cast to type t.
+
+Cast array m to type t.  t can be either a string representing a typecode,
+or a python type object of type int, float, or complex.
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('byteswap',
+"""a.byteswap(False) -> View or copy. Swap the bytes in the array.
+
+Swap the bytes in the array.  Return the byteswapped array.  If the first
+argument is TRUE, byteswap in-place and return a reference to self.
+
+"""))
+
+
 add_newdoc('numpy.core.multiarray', 'ndarray', ('choose',
 """ a.choose(b0, b1, ..., bn, out=None, mode='raise')
 
@@ -540,6 +582,21 @@
 """))
 
 
+add_newdoc('numpy.core.multiarray', 'ndarray', ('copy',
+"""a.copy(|order) -> copy, possibly with different order.
+
+Return a copy of the array.
+
+Argument:
+    order -- Order of returned copy (default 'C')
+	If order is 'C' (False) then the result is contiguous (default).
+	If order is 'Fortran' (True) then the result has fortran order.
+	If order is 'Any' (None) then the result has fortran order
+	only if m is already in fortran order.;
+
+"""))
+
+
 add_newdoc('numpy.core.multiarray', 'ndarray', ('cumprod',
 """a.cumprod(axis=None, dtype=None)
 
@@ -567,6 +624,25 @@
 """))
 
 
+add_newdoc('numpy.core.multiarray', 'ndarray', ('getfield',
+"""a.getfield(dtype, offset) -> field of array as given type.
+
+Returns a field of the given array as a certain type. A field is a view of
+the array's data with each itemsize determined by the given type and the
+offset into the current array.
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('item',
+"""a.item() ->  copy of first array item as Python scalar.
+
+Copy the first element of array to a standard Python scalar and return
+it. The array must be of size one.
+
+"""))
+
+
 add_newdoc('numpy.core.multiarray', 'ndarray', ('max',
 """a.max(axis=None)
 
@@ -653,8 +729,8 @@
 add_newdoc('numpy.core.multiarray', 'ndarray', ('repeat',
 """a.repeat(repeats=, axis=none)
 
-copy elements of a, repeats times.  the repeats argument must
-be a sequence of length a.shape[axis] or a scalar.;
+copy elements of a, repeats times.  the repeats argument must be a sequence
+of length a.shape[axis] or a scalar.
 
 """))
 
@@ -662,13 +738,22 @@
 add_newdoc('numpy.core.multiarray', 'ndarray', ('reshape',
 """a.reshape(d1, d2, ..., dn, order='c')
 
-Return a new array from this one.  The new array must have the
-same number of elements as self.  Also always returns a view or
-raises a ValueError if that is impossible.;
+Return a new array from this one.  The new array must have the same number
+of elements as self.  Also always returns a view or raises a ValueError if
+that is impossible.;
 
 """))
 
 
+add_newdoc('numpy.core.multiarray', 'ndarray', ('resize',
+"""a.resize(new_shape, refcheck=True, order=False) -> None. Change array shape.
+
+Change size and shape of self inplace.  Array must own its own memory and
+not be referenced by other arrays.    Returns None.
+
+"""))
+
+
 add_newdoc('numpy.core.multiarray', 'ndarray', ('round',
 """a.round(decimals=0, out=None)
 
@@ -678,15 +763,22 @@
 add_newdoc('numpy.core.multiarray', 'ndarray', ('searchsorted',
 """a.searchsorted(v)
 
- Assuming that a is a 1-D array, in ascending order and represents
- bin boundaries, then a.searchsorted(values) gives an array of bin
- numbers, giving the bin into which each value would be placed.
- This method is helpful for histograming.  Note: No warning is
- given if the boundaries, in a, are not in ascending order.;
+ Assuming that a is a 1-D array, in ascending order and represents bin
+ boundaries, then a.searchsorted(values) gives an array of bin numbers,
+ giving the bin into which each value would be placed.  This method is
+ helpful for histograming.  Note: No warning is given if the boundaries, in
+ a, are not in ascending order.
 
 """))
 
 
+add_newdoc('numpy.core.multiarray', 'ndarray', ('setfield',
+"""m.setfield(value, dtype, offset) -> None.
+places val into field of the given array defined by the data type and offset.
+
+"""))
+
+
 add_newdoc('numpy.core.multiarray', 'ndarray', ('setflags',
 """a.setflags(write=None, align=None, uic=None)
 
@@ -794,9 +886,32 @@
 """))
 
 
+add_newdoc('numpy.core.multiarray', 'ndarray', ('tofile',
+"""a.tofile(fid, sep="") -> None. Write the data to a file.
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('tolist',
+"""a.tolist() -> Array as hierarchical list.
+
+Copy the data portion of the array to a hierarchical python list and return
+that list.
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('tostring',
+"""a.tostring(order='C') -> binary array data as Python string.
+
+Construct a Python string containing the raw bytes in the array.
+
+"""))
+
+
 add_newdoc('numpy.core.multiarray', 'ndarray', ('trace',
 """a.trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)
-return the sum along the offset diagonal of the arrays indicated
+return the sum along the offset diagonal of the array's indicated
 axis1 and axis2.
 
 """))
@@ -840,5 +955,3 @@
 Type can be either a new sub-type object or a data-descriptor object
 
 """))
-
-

Modified: trunk/numpy/core/src/arraymethods.c
===================================================================
--- trunk/numpy/core/src/arraymethods.c	2006-08-29 02:47:39 UTC (rev 3090)
+++ trunk/numpy/core/src/arraymethods.c	2006-08-29 06:02:10 UTC (rev 3091)
@@ -228,10 +228,6 @@
 	return PyArray_SwapAxes(self, axis1, axis2);
 }
 
-static char doc_getfield[] = "m.getfield(dtype, offset) returns a field "\
-	" of the given array as a certain type. \nA field is a view of "\
-	" the array's data with each itemsize determined by the\ngiven type"\
-	" and the offset into the current array.";
 
 /* steals typed reference */
 /*OBJECT_API
@@ -280,9 +276,6 @@
 }
 
 
-static char doc_setfield[] = "m.setfield(value, dtype, offset) places val "\
-	"into field of the given array defined by the data type and offset.";
-
 /*OBJECT_API
  Set a subset of bytes from each element of the array
 */
@@ -384,9 +377,6 @@
 	}
 }
 
-static char doc_byteswap[] = "m.byteswap(False)  Swap the bytes in"\
-	" the array.  Return the byteswapped array.  If the first argument"\
-	" is TRUE, byteswap in-place and return a reference to self.";
 
 static PyObject *
 array_byteswap(PyArrayObject *self, PyObject *args)
@@ -399,9 +389,6 @@
 	return PyArray_Byteswap(self, inplace);
 }
 
-static char doc_tolist[] = "m.tolist().	 Copy the data portion of the array"\
-	" to a hierarchical python list and return that list.";
-
 static PyObject *
 array_tolist(PyArrayObject *self, PyObject *args)
 {
@@ -409,8 +396,6 @@
         return PyArray_ToList(self);
 }
 
-static char doc_tostring[] = "m.tostring(order='C')  Construct a Python string "\
-        "containing the raw bytes in the array";
 
 static PyObject *
 array_tostring(PyArrayObject *self, PyObject *args, PyObject *kwds)
@@ -424,7 +409,6 @@
         return PyArray_ToString(self, order);
 }
 
-static char doc_tofile[] = "m.tofile(fid, sep="") write the data to a file.";
 
 static PyObject *
 array_tofile(PyArrayObject *self, PyObject *args, PyObject *kwds)
@@ -461,8 +445,6 @@
         return Py_None;
 }
 
-static char doc_toscalar[] = "m.item().  Copy the first data point of "\
-	"the array to a standard Python scalar and return it.";
 
 static PyObject *
 array_toscalar(PyArrayObject *self, PyObject *args) {
@@ -476,9 +458,6 @@
 	}
 }
 
-static char doc_cast[] = "m.astype(t).	Cast array m to type t.	 \n\n"\
-	"t can be either a string representing a typecode, or a python type"\
-	" object of type int, float, or complex.";
 
 static PyObject *
 array_cast(PyArrayObject *self, PyObject *args)
@@ -585,11 +564,6 @@
 	}
 }
 
-static char doc_copy[] = "m.copy(|order). Return a copy of the array.\n"\
-	"If order is 'C' (False) then the result is contiguous (default). \n"\
-	"If order is 'Fortran' (True) then the result has fortran order. \n"\
-	"If order is 'Any' (None) then the result has fortran order \n"\
-	"only if m is already in fortran order.";
 
 static PyObject *
 array_copy(PyArrayObject *self, PyObject *args)
@@ -601,10 +575,6 @@
         return PyArray_NewCopy(self, fortran);
 }
 
-static char doc_resize[] = "self.resize(new_shape, refcheck=True, order=False).  "\
-	"Change size and shape of self inplace.\n"\
-	"\n    Array must own its own memory and not be referenced by other " \
-	"arrays\n    Returns None.";
 
 static PyObject *
 array_resize(PyArrayObject *self, PyObject *args, PyObject *kwds)
@@ -767,7 +737,6 @@
         }
 }
 
-static char doc_deepcopy[] = "Used if copy.deepcopy is called on an array.";
 
 static PyObject *
 array_deepcopy(PyArrayObject *self, PyObject *args)
@@ -1570,117 +1539,130 @@
 }
 
 static PyMethodDef array_methods[] = {
-        {"tolist",	 (PyCFunction)array_tolist,	1, doc_tolist},
-        {"item", (PyCFunction)array_toscalar, METH_VARARGS, doc_toscalar},
+        {"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, doc_tofile},
+            METH_VARARGS | METH_KEYWORDS, NULL},
+        {"tolist", (PyCFunction)array_tolist,
+            1, NULL},
         {"tostring", (PyCFunction)array_tostring,
-	 METH_VARARGS | METH_KEYWORDS, doc_tostring},
-        {"byteswap",   (PyCFunction)array_byteswap,	1, doc_byteswap},
-        {"astype", (PyCFunction)array_cast, 1, doc_cast},
-	{"getfield", (PyCFunction)array_getfield,
-	 METH_VARARGS | METH_KEYWORDS, doc_getfield},
-	{"setfield", (PyCFunction)array_setfield,
-	 METH_VARARGS | METH_KEYWORDS, doc_setfield},
-        {"copy", (PyCFunction)array_copy, 1, doc_copy},
+            METH_VARARGS | METH_KEYWORDS, NULL},
         {"resize", (PyCFunction)array_resize,
-	 METH_VARARGS | METH_KEYWORDS, doc_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},
-	{"__array_wrap__", (PyCFunction)array_wraparray, 1, doc_wraparray},
+	{"__array__", (PyCFunction)array_getarray,
+            1, doc_array_getarray},
+	{"__array_wrap__", (PyCFunction)array_wraparray,
+            1, doc_wraparray},
 
 	/* for the copy module */
-        {"__copy__", (PyCFunction)array_copy, 1, doc_copy},
-        {"__deepcopy__", (PyCFunction)array_deepcopy, 1, doc_deepcopy},
+        {"__copy__", (PyCFunction)array_copy,
+            1, NULL},
+        {"__deepcopy__", (PyCFunction)array_deepcopy,
+            1, NULL},
 
         /* for Pickling */
-        {"__reduce__", (PyCFunction) array_reduce, 1, doc_reduce},
-	{"__setstate__", (PyCFunction) array_setstate, 1, doc_setstate},
-	{"dumps", (PyCFunction) array_dumps, 1, doc_dumps},
-	{"dump", (PyCFunction) array_dump, 1, doc_dump},
+        {"__reduce__", (PyCFunction) array_reduce,
+            1, doc_reduce},
+	{"__setstate__", (PyCFunction) array_setstate,
+            1, doc_setstate},
+	{"dumps", (PyCFunction) array_dumps,
+            1, doc_dumps},
+	{"dump", (PyCFunction) array_dump,
+            1, doc_dump},
 
 	/* Extended methods added 2005 */
-	{"all", (PyCFunction)array_all,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+        {"all", (PyCFunction)array_all,
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"any", (PyCFunction)array_any,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
-	{"argmax",	(PyCFunction)array_argmax,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
-	{"argmin",  (PyCFunction)array_argmin,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
-	{"argsort",	(PyCFunction)array_argsort,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
-	{"choose",	(PyCFunction)array_choose,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
+	{"argmax", (PyCFunction)array_argmax,
+	    METH_VARARGS|METH_KEYWORDS, NULL},
+	{"argmin", (PyCFunction)array_argmin,
+	    METH_VARARGS|METH_KEYWORDS, NULL},
+	{"argsort", (PyCFunction)array_argsort,
+	    METH_VARARGS|METH_KEYWORDS, NULL},
+	{"choose", (PyCFunction)array_choose,
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"clip", (PyCFunction)array_clip,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"compress", (PyCFunction)array_compress,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"conj", (PyCFunction)array_conjugate,
-	 METH_VARARGS, NULL},
+	    METH_VARARGS, NULL},
 	{"conjugate", (PyCFunction)array_conjugate,
-	 METH_VARARGS, NULL},
+	    METH_VARARGS, NULL},
 	{"cumprod", (PyCFunction)array_cumprod,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"cumsum", (PyCFunction)array_cumsum,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"diagonal", (PyCFunction)array_diagonal,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"fill", (PyCFunction)array_fill,
-	 METH_VARARGS, NULL},
+	    METH_VARARGS, NULL},
 	{"flatten", (PyCFunction)array_flatten,
-	 METH_VARARGS, NULL},
+	    METH_VARARGS, NULL},
 	{"max", (PyCFunction)array_max,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"mean", (PyCFunction)array_mean,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"min", (PyCFunction)array_min,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"newbyteorder", (PyCFunction)array_newbyteorder,
-	 METH_VARARGS, NULL},
+	    METH_VARARGS, NULL},
 	{"nonzero", (PyCFunction)array_nonzero,
-	 METH_VARARGS, NULL},
+	    METH_VARARGS, NULL},
 	{"prod", (PyCFunction)array_prod,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"ptp", (PyCFunction)array_ptp,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"put",	(PyCFunction)array_put,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
-	{"putmask",	(PyCFunction)array_putmask,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
+	{"putmask", (PyCFunction)array_putmask,
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"ravel", (PyCFunction)array_ravel,
-	 METH_VARARGS, NULL},
-	{"repeat",	(PyCFunction)array_repeat,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
-	{"reshape",	(PyCFunction)array_reshape,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS, NULL},
+	{"repeat", (PyCFunction)array_repeat,
+	    METH_VARARGS|METH_KEYWORDS, NULL},
+	{"reshape", (PyCFunction)array_reshape,
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"round", (PyCFunction)array_round,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
-	{"searchsorted",  (PyCFunction)array_searchsorted,
-	 METH_VARARGS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
+	{"searchsorted", (PyCFunction)array_searchsorted,
+	    METH_VARARGS, NULL},
 	{"setflags", (PyCFunction)array_setflags,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
-	{"sort",	(PyCFunction)array_sort,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
-	{"squeeze",	(PyCFunction)array_squeeze,
-	 METH_VARARGS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
+	{"sort", (PyCFunction)array_sort,
+	    METH_VARARGS|METH_KEYWORDS, NULL},
+	{"squeeze", (PyCFunction)array_squeeze,
+	    METH_VARARGS, NULL},
 	{"std", (PyCFunction)array_stddev,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"sum", (PyCFunction)array_sum,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"swapaxes", (PyCFunction)array_swapaxes,
-	 METH_VARARGS, NULL},
-	{"take",	(PyCFunction)array_take,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
+	    METH_VARARGS, NULL},
+	{"take", (PyCFunction)array_take,
+	    METH_VARARGS|METH_KEYWORDS, NULL},
 	{"trace", (PyCFunction)array_trace,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
-	{"transpose",	(PyCFunction)array_transpose,
-	 METH_VARARGS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
+	{"transpose", (PyCFunction)array_transpose,
+	    METH_VARARGS, NULL},
 	{"var", (PyCFunction)array_variance,
-	 METH_VARARGS|METH_KEYWORDS, NULL},
-	{"view",  (PyCFunction)array_view,
-	 METH_VARARGS, NULL},
+	    METH_VARARGS|METH_KEYWORDS, NULL},
+	{"view", (PyCFunction)array_view,
+	    METH_VARARGS, NULL},
         {NULL,		NULL}		/* sentinel */
 };
 



More information about the Numpy-svn mailing list