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

numpy-svn at scipy.org numpy-svn at scipy.org
Sun Aug 27 19:37:17 CDT 2006


Author: charris
Date: 2006-08-27 19:37:14 -0500 (Sun, 27 Aug 2006)
New Revision: 3083

Modified:
   trunk/numpy/add_newdocs.py
   trunk/numpy/core/src/arraymethods.c
Log:
Move most of the remaining documentation from arraymethods to add_newdocs.
The formatting is still very crude and the docs need expansion.


Modified: trunk/numpy/add_newdocs.py
===================================================================
--- trunk/numpy/add_newdocs.py	2006-08-27 18:08:18 UTC (rev 3082)
+++ trunk/numpy/add_newdocs.py	2006-08-28 00:37:14 UTC (rev 3083)
@@ -35,56 +35,6 @@
             ]
            )
 
-add_newdoc('numpy.core', 'ndarray',
-"""An array object represents a multidimensional, homogeneous array
-of fixed-size items.  An associated data-type-descriptor object
-details the data-type in an array (including byteorder and any
-fields).  An array can be constructed using the numpy.array
-command. Arrays are sequence, mapping and numeric objects.
-More information is available in the numpy module and by looking
-at the methods and attributes of an array.
-
-ndarray.__new__(subtype, shape=, dtype=float, buffer=None,
-                offset=0, strides=None, order=None)
-
- There are two modes of creating an array using __new__:
- 1) If buffer is None, then only shape, dtype, and order
-    are used
- 2) If buffer is an object exporting the buffer interface, then
-    all keywords are interpreted.
- The dtype parameter can be any object that can be interpreted
-    as a numpy.dtype object.
-
- No __init__ method is needed because the array is fully
- initialized after the __new__ method.
-"""
-           )
-
-add_newdoc('numpy.core', 'ndarray',
-           [('ndim', 'number of array dimensions'),
-            ('flags', 'special object providing array flags'),
-            ('shape', 'tuple of array dimensions'),
-            ('strides', 'tuple of bytes to step in each dimension'),
-            ('data', 'buffer object pointing to the start of the data'),
-            ('itemsize', 'length of one element in bytes'),
-            ('size', 'number of elements in the array'),
-            ('nbytes', 'number of bytes in the array'),
-            ('base', 'base object if memory is from some other object'),
-            ('dtype', 'data-type for the array'),
-            ('real', 'real part of the array'),
-            ('imag', 'imaginary part of the array'),
-            ('flat', 'a 1-d flat iterator'),
-            ('ctypes', 'a ctypes interface object'),
-            ('_as_parameter_', 'allow the array to be interpreted as a ctypes object by returning the data-memory location as an integer'),
-            ('T', 'equivalent to self.transpose() except self is returned for self.ndim < 2'),
-            ('__array_interface__', 'Array protocol: Python side'),
-            ('__array_struct__', 'Array protocol: C-struct side'),
-            ('__array_priority__', 'Array priority'),
-            ('__array_finalize__', 'None')
-            ]
-           )
-
-
 add_newdoc('numpy.core', 'flatiter',
            [('__array__',
 """__array__(type=None)
@@ -357,42 +307,99 @@
 
 """)
 
-add_newdoc('numpy.core.multiarray', 'ndarray', ('sort',
-"""a.sort(axis=-1, kind='quicksort') -> None. Sort a along the given axis.
+##############################################################################
+#
+# Documentation for ndarray attributes and methods
+#
+# Todo:
+#
+# break out attributes separately
+#
+# Attributes and module documentation are still defined elsewhere,
+# so don't show up yet.
+#
+# expand and reformat other documentation.
+#
+# all methods prior to Extended methods added 2005
+#
+##############################################################################
 
-Keyword arguments:
 
-axis -- axis to be sorted (default -1)
-kind -- sorting algorithm (default 'quicksort')
-        Possible values: 'quicksort', 'mergesort', or 'heapsort'.
+add_newdoc('numpy.core.multiarray', 'ndarray',
+"""An array object represents a multidimensional, homogeneous array
+of fixed-size items.  An associated data-type-descriptor object
+details the data-type in an array (including byteorder and any
+fields).  An array can be constructed using the numpy.array
+command. Arrays are sequence, mapping and numeric objects.
+More information is available in the numpy module and by looking
+at the methods and attributes of an array.
 
-Returns: None.
+ndarray.__new__(subtype, shape=, dtype=float, buffer=None,
+                offset=0, strides=None, order=None)
 
-This method sorts a in place along the given axis using the algorithm
-specified by the kind keyword.
+ There are two modes of creating an array using __new__:
+ 1) If buffer is None, then only shape, dtype, and order
+    are used
+ 2) If buffer is an object exporting the buffer interface, then
+    all keywords are interpreted.
+ The dtype parameter can be any object that can be interpreted
+    as a numpy.dtype object.
 
-The various sorts may characterized by average speed, worst case
-performance, need for work space, and whether they are stable. A stable
-sort keeps items with the same key in the same relative order and is most
-useful when used with argsort where the key might differ from the items
-being sorted. The three available algorithms have the following properties:
+ No __init__ method is needed because the array is fully
+ initialized after the __new__ method.
+""")
 
-|------------------------------------------------------|
-|    kind   | speed |  worst case | work space | stable|
-|------------------------------------------------------|
-|'quicksort'|   1   |    o(n)     |      0     |   no  |
-|'mergesort'|   2   | o(n*log(n)) |    ~n/2    |   yes |
-|'heapsort' |   3   | o(n*log(n)) |      0     |   no  |
-|------------------------------------------------------|
 
-All the sort algorithms make temporary copies of the data when the sort is
-not along the last axis. Consequently, sorts along the last axis are faster
-and use less space than sorts along other axis.
+add_newdoc('numpy.core.multiarray', 'ndarray',
+           [('ndim', 'number of array dimensions'),
+            ('flags', 'special object providing array flags'),
+            ('shape', 'tuple of array dimensions'),
+            ('strides', 'tuple of bytes to step in each dimension'),
+            ('data', 'buffer object pointing to the start of the data'),
+            ('itemsize', 'length of one element in bytes'),
+            ('size', 'number of elements in the array'),
+            ('nbytes', 'number of bytes in the array'),
+            ('base', 'base object if memory is from some other object'),
+            ('dtype', 'data-type for the array'),
+            ('real', 'real part of the array'),
+            ('imag', 'imaginary part of the array'),
+            ('flat', 'a 1-d flat iterator'),
+            ('ctypes', 'a ctypes interface object'),
+            ('_as_parameter_', 'allow the array to be interpreted as a ctypes object by returning the data-memory location as an integer'),
+            ('T', 'equivalent to self.transpose() except self is returned for self.ndim < 2'),
+            ('__array_interface__', 'Array protocol: Python side'),
+            ('__array_struct__', 'Array protocol: C-struct side'),
+            ('__array_priority__', 'Array priority'),
+            ('__array_finalize__', 'None')
+            ])
 
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('all',
+""" a.all(axis=None)
+
 """))
 
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('any',
+""" a.any(axis=None, out=None)
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('argmax',
+""" a.argmax(axis=None, out=None)
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('argmin',
+""" a.argmin(axis=None, out=None)
+
+"""))
+
+
 add_newdoc('numpy.core.multiarray', 'ndarray', ('argsort',
-"""a.sort(axis=-1, kind='quicksort') -> indices that sort a along given axis.
+"""a.argsort(axis=-1, kind='quicksort') -> indices that sort a along given axis.
 
 Keyword arguments:
 
@@ -425,6 +432,176 @@
 
 """))
 
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('choose',
+""" a.choose(b0, b1, ..., bn, out=None, mode='raise')
+
+Return an array that merges the b_i arrays together using 'a' as
+the index The b_i arrays and 'a' must all be broadcastable to the
+same shape.  The output at a particular position is the input
+array b_i at that position depending on the value of 'a' at that
+position.  Therefore, 'a' must be an integer array with entries
+from 0 to n+1.;
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('clip',
+"""a.clip(min=, max=, out=None)
+
+"""))
+
+
+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()
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('cumprod',
+"""a.cumprod(axis=None, dtype=None)
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('cumsum',
+"""a.cumsum(axis=None, dtype=None, out=None)
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('diagonal',
+"""a.diagonal(offset=0, axis1=0, axis2=1)
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('fill',
+"""a.fill(value) -> None. Fill the array with the scalar value.
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('flatten',
+"""a.flatten([fortran]) return a 1-d array (always copy)
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('max',
+"""a.max(axis=None)
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('mean',
+"""a.mean(axis=None, dtype=None)
+
+  Average the array over the given axis.  If the axis is None,
+  average over all dimensions of the array.  If an integer axis
+  is given, this equals:
+      a.sum(axis, dtype) * 1.0 / len(a).
+  If axis is None, this equals:
+      a.sum(axis, dtype) * 1.0 / product(a.shape)
+  The optional dtype argument is the data type for intermediate
+  calculations in the sum.;
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('min',
+"""a.min(axis=None)
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('newbyteorder',
+"""a.newbyteorder(<byteorder>) is equivalent to
+a.view(a.dtype.newbytorder(<byteorder>))
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('nonzero',
+"""a.nonzero() returns a tuple of arrays
+
+Returns a tuple of arrays, one for each dimension of a,
+containing the indices of the non-zero elements in that
+dimension.  The corresponding non-zero values can be obtained
+with
+    a[a.nonzero()].
+
+To group the indices by element, rather than dimension, use
+    transpose(a.nonzero())
+instead. The result of this is always a 2d array, with a row for
+each non-zero element.;
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('prod',
+""" a.prod(axis=None, dtype=None)
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('ptp',
+"""a.ptp(axis=None) a.max(axis)-a.min(axis)
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('put',
+"""a.put(values, indices, mode) sets a.flat[n] = values[n] for
+each n in indices. v can be scalar or shorter than indices, and
+it will repeat.
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('putmask',
+"""a.putmask(values, mask) sets a.flat[n] = v[n] for each n where
+mask.flat[n] is true. v can be scalar.
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('ravel',
+"""a.ravel([fortran]) return a 1-d array (copy only if needed)
+
+"""))
+
+
+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.;
+
+"""))
+
+
+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.;
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('round',
+"""a.round(decimals=0, out=None)
+
+"""))
+
+
 add_newdoc('numpy.core.multiarray', 'ndarray', ('searchsorted',
 """a.searchsorted(v)
 
@@ -435,3 +612,160 @@
  given if the boundaries, in a, are not in ascending order.;
 
 """))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('setflags',
+"""a.setflags(write=None, align=None, uic=None)
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('sort',
+"""a.sort(axis=-1, kind='quicksort') -> None. Sort a along the given axis.
+
+Keyword arguments:
+
+axis -- axis to be sorted (default -1)
+kind -- sorting algorithm (default 'quicksort')
+        Possible values: 'quicksort', 'mergesort', or 'heapsort'.
+
+Returns: None.
+
+This method sorts a in place along the given axis using the algorithm
+specified by the kind keyword.
+
+The various sorts may characterized by average speed, worst case
+performance, need for work space, and whether they are stable. A stable
+sort keeps items with the same key in the same relative order and is most
+useful when used with argsort where the key might differ from the items
+being sorted. The three available algorithms have the following properties:
+
+|------------------------------------------------------|
+|    kind   | speed |  worst case | work space | stable|
+|------------------------------------------------------|
+|'quicksort'|   1   |    o(n)     |      0     |   no  |
+|'mergesort'|   2   | o(n*log(n)) |    ~n/2    |   yes |
+|'heapsort' |   3   | o(n*log(n)) |      0     |   no  |
+|------------------------------------------------------|
+
+All the sort algorithms make temporary copies of the data when the sort is
+not along the last axis. Consequently, sorts along the last axis are faster
+and use less space than sorts along other axis.
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('squeeze',
+"""m.squeeze() eliminate all length-1 dimensions
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('std',
+"""a.std(axis=None, dtype=None, out=None) -> standard deviation.
+
+The standard deviation isa measure of the spread of a
+distribution.
+
+The standard deviation is the square root of the average of the
+squared deviations from the mean, i.e.
+    std = sqrt(mean((x - x.mean())**2)).
+
+For multidimensional arrays, std is computed by default along the
+first axis.
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('sum',
+"""a.sum(axis=None, dtype=None) -> Sum of array over given axis.
+
+Sum the array over the given axis.  If the axis is None, sum over
+all dimensions of the array.
+
+The optional dtype argument is the data type for the returned
+value and intermediate calculations.  The default is to upcast
+(promote) smaller integer types to the platform-dependent int.
+For example, on 32-bit platforms:
+
+  a.dtype                         default sum() dtype
+  ---------------------------------------------------
+  bool, int8, int16, int32        int32
+
+Examples:
+
+>>> array([0.5, 1.5]).sum()
+2.0
+>>> array([0.5, 1.5]).sum(dtype=int32)
+1
+>>> array([[0, 1], [0, 5]]).sum(axis=0)
+array([0, 6])
+>>> array([[0, 1], [0, 5]]).sum(axis=1)
+array([1, 5])
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('swapaxes',
+"""a.swapaxes(axis1, axis2) -> new view with axes swapped.
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('take',
+"""a.take(indices, axis=None, out=None, mode='raise') -> new array.
+
+The new array is formed from the elements of a indexed by indices along the
+given axis.
+
+"""))
+
+
+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
+axis1 and axis2.
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('transpose',
+"""a.transpose(*axes)
+
+Returns a view of 'a' with axes transposed. If no axes are given,
+or None is passed, switches the order of the axes. For a 2-d
+array, this is the usual matrix transpose. If axes are given,
+they describe how the axes are permuted.
+
+Example:
+>>> a = array([[1,2],[3,4]])
+>>> a
+array([[1, 2],
+       [3, 4]])
+>>> a.transpose()
+array([[1, 3],
+       [2, 4]])
+>>> a.transpose((1,0))
+array([[1, 3],
+       [2, 4]])
+>>> a.transpose(1,0)
+array([[1, 3],
+       [2, 4]])
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('var',
+"""a.var(axis=None, dtype=None)
+
+"""))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('view',
+"""a.view(<type>) -> new view of array with same data.
+
+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-27 18:08:18 UTC (rev 3082)
+++ trunk/numpy/core/src/arraymethods.c	2006-08-28 00:37:14 UTC (rev 3083)
@@ -2,9 +2,6 @@
 /* Should only be used if x is known to be an nd-array */
 #define _ARET(x) PyArray_Return((PyArrayObject *)(x))
 
-static char doc_take[] = "a.take(indices, axis=None, out=None, mode='raise')."\
-        "Selects the elements in indices from array a along the given axis.";
-
 static PyObject *
 array_take(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -27,9 +24,6 @@
 	return _ARET(PyArray_TakeFrom(self, indices, dimension, out, mode));
 }
 
-static char doc_fill[] = "a.fill(value) places the scalar value at every "\
-	"position in the array.";
-
 static PyObject *
 array_fill(PyArrayObject *self, PyObject *args)
 {
@@ -41,10 +35,6 @@
 	return Py_None;
 }
 
-static char doc_put[] = "a.put(values, indices, mode) sets a.flat[n] = "\
-        "values[n] for\n" "each n in indices. v can be scalar or shorter "\
-        "than indices,\n" "and it will repeat.";
-
 static PyObject *
 array_put(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -60,9 +50,6 @@
 	return PyArray_PutTo(self, values, indices, mode);
 }
 
-static char doc_putmask[] = "a.putmask(values, mask) sets a.flat[n] = v[n] "\
-	"for each n where mask.flat[n] is TRUE. v can be scalar.";
-
 static PyObject *
 array_putmask(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -76,13 +63,6 @@
 	return PyArray_PutMask(self, values, mask);
 }
 
-static char doc_reshape[] = \
-	"self.reshape(d1, d2, ..., dn, order='C') \n"
-	"Return a new array from this one. \n"
-	"\n  The new array must have the same number of elements as self. "
-	"Also\n always returns a view or raises a ValueError if that is \n"
-	"impossible.";
-
 static PyObject *
 array_reshape(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -122,8 +102,6 @@
 	return NULL;
 }
 
-static char doc_squeeze[] = "m.squeeze() eliminate all length-1 dimensions";
-
 static PyObject *
 array_squeeze(PyArrayObject *self, PyObject *args)
 {
@@ -131,8 +109,6 @@
         return PyArray_Squeeze(self);
 }
 
-static char doc_view[] = "a.view(<type>) return a new view of array with same data. type can be either a new sub-type object or a data-descriptor object";
-
 static PyObject *
 array_view(PyArrayObject *self, PyObject *args)
 {
@@ -156,8 +132,6 @@
 	return PyArray_View(self, type, NULL);
 }
 
-static char doc_argmax[] = "a.argmax(axis=None, out=None)";
-
 static PyObject *
 array_argmax(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -175,8 +149,6 @@
 	return _ARET(PyArray_ArgMax(self, axis, out));
 }
 
-static char doc_argmin[] = "a.argmin(axis=None, out=None)";
-
 static PyObject *
 array_argmin(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -194,8 +166,6 @@
 	return _ARET(PyArray_ArgMin(self, axis, out));
 }
 
-static char doc_max[] = "a.max(axis=None)";
-
 static PyObject *
 array_max(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -213,8 +183,6 @@
 	return PyArray_Max(self, axis, out);
 }
 
-static char doc_ptp[] = "a.ptp(axis=None) a.max(axis)-a.min(axis)";
-
 static PyObject *
 array_ptp(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -233,8 +201,6 @@
 }
 
 
-static char doc_min[] = "a.min(axis=None)";
-
 static PyObject *
 array_min(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -252,8 +218,6 @@
 	return PyArray_Min(self, axis, out);
 }
 
-static char doc_swapaxes[] = "a.swapaxes(axis1, axis2)  returns new view with axes swapped.";
-
 static PyObject *
 array_swapaxes(PyArrayObject *self, PyObject *args)
 {
@@ -687,11 +651,6 @@
 	return Py_None;
 }
 
-static char doc_repeat[] = "a.repeat(repeats=, axis=None)\n"\
-	"\n"\
-	" Copy elements of a, repeats times.  The repeats argument must\n"\
-	"  be a sequence of length a.shape[axis] or a scalar.";
-
 static PyObject *
 array_repeat(PyArrayObject *self, PyObject *args, PyObject *kwds) {
 	PyObject *repeats;
@@ -705,14 +664,6 @@
 	return _ARET(PyArray_Repeat(self, repeats, axis));
 }
 
-static char doc_choose[] = "a.choose(b0, b1, ..., bn, out=None, mode='raise')\n"\
-	"\n"                                                            \
-	"Return an array that merges the b_i arrays together using 'a' as the index\n"
-        "The b_i arrays and 'a' must all be broadcastable to the same shape.\n"
-        "The output at a particular position is the input array b_i at that position\n"
-        "depending on the value of 'a' at that position.  Therefore, 'a' must be\n"
-        "an integer array with entries from 0 to n+1.";
-
 static PyObject *
 array_choose(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -1215,27 +1166,6 @@
 }
 
 
-static char doc_transpose[] = "a.transpose(*axes)\n\n"
-"Returns a view of `a` with axes transposed. If no axes are given,\n"
-"or None is passed, switches the order of the axes (for a 2-d array,\n"
-"this is the usual matrix transpose). If axes are given, they\n"
-"describe how the axes are permuted.\n\n"
-"Example:\n"
-">>> a = array([[1,2],[3,4]])\n"
-">>> a\n"
-"array([[1, 2],\n"
-"       [3, 4]])\n"
-">>> a.transpose()\n"
-"array([[1, 3],\n"
-"       [2, 4]])\n"
-">>> a.transpose((1,0))\n"
-"array([[1, 3],\n"
-"       [2, 4]])\n"
-">>> a.transpose(1,0)\n"
-"array([[1, 3],\n"
-"       [2, 4]])\n"
-;
-
 static PyObject *
 array_transpose(PyArrayObject *self, PyObject *args)
 {
@@ -1259,19 +1189,6 @@
 	return _ARET(ret);
 }
 
-static char doc_mean[] = "a.mean(axis=None, dtype=None)\n\n"\
-  "Average the array over the given axis.  If the axis is None, average\n"\
-  "over all dimensions of the array.\n"\
-  "\n"\
-  "If an integer axis is given, this equals:\n"\
-  "    a.sum(axis, dtype) * 1.0 / len(a)\n"\
-  "\n"\
-  "If axis is None, this equals:\n"\
-  "     a.sum(axis, dtype) * 1.0 / product(a.shape)\n"\
-  "\n"\
-  "The optional dtype argument is the data type for intermediate\n"\
-  "calculations in the sum.";
-
 #define _CHKTYPENUM(typ) ((typ) ? (typ)->type_num : PyArray_NOTYPE)
 
 static PyObject *
@@ -1292,30 +1209,6 @@
 	return PyArray_Mean(self, axis, _CHKTYPENUM(dtype), out);
 }
 
-static char doc_sum[] = "a.sum(axis=None, dtype=None)\n\n"\
-  "Sum the array over the given axis.  If the axis is None, sum over all\n"\
-  "dimensions of the array.\n"\
-  "\n"\
-  "The optional dtype argument is the data type for the returned value\n"\
-  "and intermediate calculations.  The default is to upcast (promote)\n"\
-  "smaller integer types to the platform-dependent int.  For example, on\n"\
-  "32-bit platforms:\n"\
-  "\n"\
-  "    a.dtype                         default sum() dtype\n"\
-  "    ---------------------------------------------------\n"\
-  "    bool, int8, int16, int32        int32\n"\
-  "\n"\
-  "Examples:\n"\
-  "\n"\
-  ">>> array([0.5, 1.5]).sum()\n"\
-  "2.0\n"\
-  ">>> array([0.5, 1.5]).sum(dtype=int32)\n"\
-  "1\n"\
-  ">>> array([[0, 1], [0, 5]]).sum(axis=0)\n"\
-  "array([0, 6])\n"\
-  ">>> array([[0, 1], [0, 5]]).sum(axis=1)\n"\
-  "array([1, 5])";
-
 static PyObject *
 array_sum(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -1335,8 +1228,6 @@
 }
 
 
-static char doc_cumsum[] = "a.cumsum(axis=None, dtype=None, out=None)";
-
 static PyObject *
 array_cumsum(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -1355,8 +1246,6 @@
 	return PyArray_CumSum(self, axis, _CHKTYPENUM(dtype), out);
 }
 
-static char doc_prod[] = "a.prod(axis=None, dtype=None)";
-
 static PyObject *
 array_prod(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -1375,9 +1264,6 @@
 	return PyArray_Prod(self, axis, _CHKTYPENUM(dtype), out);
 }
 
-
-static char doc_cumprod[] = "a.cumprod(axis=None, dtype=None)";
-
 static PyObject *
 array_cumprod(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -1397,8 +1283,6 @@
 }
 
 
-static char doc_any[] = "a.any(axis=None, out=None)";
-
 static PyObject *
 array_any(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -1416,7 +1300,6 @@
 	return PyArray_Any(self, axis, out);
 }
 
-static char doc_all[] = "a.all(axis=None)";
 
 static PyObject *
 array_all(PyArrayObject *self, PyObject *args, PyObject *kwds)
@@ -1435,13 +1318,6 @@
 	return PyArray_All(self, axis, out);
 }
 
-static char doc_stddev[] = "a.std(axis=None, dtype=None, out=None)\n"
-"Return the standard deviation, a measure of the spread of a distribution.\n"
-"\n"
-"The standard deviation is the square root of the average of the squared\n"
-"deviations from the mean, i.e. std = sqrt(mean((x - x.mean())**2)).\n"
-"\n"
-"For multidimensional arrays, std is computed by default along the first axis.\n";
 
 static PyObject *
 array_stddev(PyArrayObject *self, PyObject *args, PyObject *kwds)
@@ -1461,7 +1337,6 @@
 	return PyArray_Std(self, axis, _CHKTYPENUM(dtype), out, 0);
 }
 
-static char doc_variance[] = "a.var(axis=None, dtype=None)";
 
 static PyObject *
 array_variance(PyArrayObject *self, PyObject *args, PyObject *kwds)
@@ -1481,7 +1356,6 @@
 	return PyArray_Std(self, axis, _CHKTYPENUM(dtype), out, 1);
 }
 
-static char doc_compress[] = "a.compress(condition=, axis=None, out=None)";
 
 static PyObject *
 array_compress(PyArrayObject *self, PyObject *args, PyObject *kwds)
@@ -1500,16 +1374,6 @@
 	return _ARET(PyArray_Compress(self, condition, axis, out));
 }
 
-static char doc_nonzero[] = \
-    "a.nonzero() returns a tuple of arrays, one for each dimension of a,\n"\
-    "containing the indices of the non-zero elements in that dimension.\n"\
-    "The corresponding non-zero values can be obtained with\n"\
-    "    a[a.nonzero()].\n"
-    "\n"\
-    "To group the indices by element, rather than dimension, use\n"\
-    "    transpose(a.nonzero())\n"\
-    "instead. The result of this is always a 2d array, with a row for each\n"\
-    "non-zero element.";
 
 static PyObject *
 array_nonzero(PyArrayObject *self, PyObject *args)
@@ -1520,10 +1384,6 @@
 }
 
 
-static char doc_trace[] = "a.trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)\n"\
-	"return the sum along the offset diagonal of the arrays indicated\n" \
-	"axis1 and axis2.";
-
 static PyObject *
 array_trace(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -1545,8 +1405,6 @@
 #undef _CHKTYPENUM
 
 
-static char doc_clip[] = "a.clip(min=, max=, out=None)";
-
 static PyObject *
 array_clip(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -1563,10 +1421,7 @@
 	return _ARET(PyArray_Clip(self, min, max, out));
 }
 
-static char doc_conj[] = "a.conj()";
 
-static char doc_conjugate[] = "a.conjugate()";
-
 static PyObject *
 array_conjugate(PyArrayObject *self, PyObject *args)
 {
@@ -1580,8 +1435,6 @@
 }
 
 
-static char doc_diagonal[] = "a.diagonal(offset=0, axis1=0, axis2=1)";
-
 static PyObject *
 array_diagonal(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
@@ -1595,7 +1448,6 @@
 	return _ARET(PyArray_Diagonal(self, offset, axis1, axis2));
 }
 
-static char doc_flatten[] = "a.flatten([fortran]) return a 1-d array (always copy)";
 
 static PyObject *
 array_flatten(PyArrayObject *self, PyObject *args)
@@ -1608,7 +1460,6 @@
 	return PyArray_Flatten(self, fortran);
 }
 
-static char doc_ravel[] = "a.ravel([fortran]) return a 1-d array (copy only if needed)";
 
 static PyObject *
 array_ravel(PyArrayObject *self, PyObject *args)
@@ -1621,7 +1472,6 @@
 	return PyArray_Ravel(self, fortran);
 }
 
-static char doc_round[] = "a.round(decimals=0, out=None)";
 
 static PyObject *
 array_round(PyArrayObject *self, PyObject *args, PyObject *kwds)
@@ -1639,7 +1489,6 @@
 }
 
 
-static char doc_setflags[] = "a.setflags(write=None, align=None, uic=None)";
 
 static int _IsAligned(PyArrayObject *);
 static Bool _IsWriteable(PyArrayObject *);
@@ -1704,8 +1553,6 @@
         return Py_None;
 }
 
-static char doc_newbyteorder[] = "a.newbyteorder(<byteorder>) is equivalent\n" \
-	" to a.view(a.dtype.newbytorder(<byteorder>))\n";
 
 static PyObject *
 array_newbyteorder(PyArrayObject *self, PyObject *args)
@@ -1754,86 +1601,86 @@
 	{"dump", (PyCFunction) array_dump, 1, doc_dump},
 
 	/* Extended methods added 2005 */
-	{"fill", (PyCFunction)array_fill,
-	 METH_VARARGS, doc_fill},
-	{"transpose",	(PyCFunction)array_transpose,
-	 METH_VARARGS, doc_transpose},
-	{"take",	(PyCFunction)array_take,
-	 METH_VARARGS|METH_KEYWORDS, doc_take},
-	{"put",	(PyCFunction)array_put,
-	 METH_VARARGS|METH_KEYWORDS, doc_put},
-	{"putmask",	(PyCFunction)array_putmask,
-	 METH_VARARGS|METH_KEYWORDS, doc_putmask},
-	{"repeat",	(PyCFunction)array_repeat,
-	 METH_VARARGS|METH_KEYWORDS, doc_repeat},
-	{"choose",	(PyCFunction)array_choose,
-	 METH_VARARGS|METH_KEYWORDS, doc_choose},
-	{"sort",	(PyCFunction)array_sort,
+	{"all", (PyCFunction)array_all,
 	 METH_VARARGS|METH_KEYWORDS, NULL},
-	{"argsort",	(PyCFunction)array_argsort,
+	{"any", (PyCFunction)array_any,
 	 METH_VARARGS|METH_KEYWORDS, NULL},
-	{"searchsorted",  (PyCFunction)array_searchsorted,
-	 METH_VARARGS, NULL},
 	{"argmax",	(PyCFunction)array_argmax,
-	 METH_VARARGS|METH_KEYWORDS, doc_argmax},
+	 METH_VARARGS|METH_KEYWORDS, NULL},
 	{"argmin",  (PyCFunction)array_argmin,
-	 METH_VARARGS|METH_KEYWORDS, doc_argmin},
-	{"reshape",	(PyCFunction)array_reshape,
-	 METH_VARARGS|METH_KEYWORDS, doc_reshape},
-	{"squeeze",	(PyCFunction)array_squeeze,
-	 METH_VARARGS, doc_squeeze},
-	{"view",  (PyCFunction)array_view,
-	 METH_VARARGS, doc_view},
-	{"swapaxes", (PyCFunction)array_swapaxes,
-	 METH_VARARGS, doc_swapaxes},
-	{"max", (PyCFunction)array_max,
-	 METH_VARARGS|METH_KEYWORDS, doc_max},
-	{"min", (PyCFunction)array_min,
-	 METH_VARARGS|METH_KEYWORDS, doc_min},
-	{"ptp", (PyCFunction)array_ptp,
-	 METH_VARARGS|METH_KEYWORDS, doc_ptp},
-	{"mean", (PyCFunction)array_mean,
-	 METH_VARARGS|METH_KEYWORDS, doc_mean},
-	{"trace", (PyCFunction)array_trace,
-	 METH_VARARGS|METH_KEYWORDS, doc_trace},
-	{"diagonal", (PyCFunction)array_diagonal,
-	 METH_VARARGS|METH_KEYWORDS, doc_diagonal},
+	 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, doc_clip},
+	 METH_VARARGS|METH_KEYWORDS, NULL},
+	{"compress", (PyCFunction)array_compress,
+	 METH_VARARGS|METH_KEYWORDS, NULL},
 	{"conj", (PyCFunction)array_conjugate,
-	 METH_VARARGS, doc_conj},
+	 METH_VARARGS, NULL},
 	{"conjugate", (PyCFunction)array_conjugate,
-	 METH_VARARGS, doc_conjugate},
-	{"nonzero", (PyCFunction)array_nonzero,
-	 METH_VARARGS, doc_nonzero},
-	{"std", (PyCFunction)array_stddev,
-	 METH_VARARGS|METH_KEYWORDS, doc_stddev},
-	{"var", (PyCFunction)array_variance,
-	 METH_VARARGS|METH_KEYWORDS, doc_variance},
-	{"sum", (PyCFunction)array_sum,
-	 METH_VARARGS|METH_KEYWORDS, doc_sum},
-	{"cumsum", (PyCFunction)array_cumsum,
-	 METH_VARARGS|METH_KEYWORDS, doc_cumsum},
-	{"prod", (PyCFunction)array_prod,
-	 METH_VARARGS|METH_KEYWORDS, doc_prod},
+	 METH_VARARGS, NULL},
 	{"cumprod", (PyCFunction)array_cumprod,
-	 METH_VARARGS|METH_KEYWORDS, doc_cumprod},
-	{"all", (PyCFunction)array_all,
-	 METH_VARARGS|METH_KEYWORDS, doc_all},
-	{"any", (PyCFunction)array_any,
-	 METH_VARARGS|METH_KEYWORDS, doc_any},
-	{"compress", (PyCFunction)array_compress,
-	 METH_VARARGS|METH_KEYWORDS, doc_compress},
+	 METH_VARARGS|METH_KEYWORDS, NULL},
+	{"cumsum", (PyCFunction)array_cumsum,
+	 METH_VARARGS|METH_KEYWORDS, NULL},
+	{"diagonal", (PyCFunction)array_diagonal,
+	 METH_VARARGS|METH_KEYWORDS, NULL},
+	{"fill", (PyCFunction)array_fill,
+	 METH_VARARGS, NULL},
 	{"flatten", (PyCFunction)array_flatten,
-	 METH_VARARGS, doc_flatten},
+	 METH_VARARGS, NULL},
+	{"max", (PyCFunction)array_max,
+	 METH_VARARGS|METH_KEYWORDS, NULL},
+	{"mean", (PyCFunction)array_mean,
+	 METH_VARARGS|METH_KEYWORDS, NULL},
+	{"min", (PyCFunction)array_min,
+	 METH_VARARGS|METH_KEYWORDS, NULL},
+	{"newbyteorder", (PyCFunction)array_newbyteorder,
+	 METH_VARARGS, NULL},
+	{"nonzero", (PyCFunction)array_nonzero,
+	 METH_VARARGS, NULL},
+	{"prod", (PyCFunction)array_prod,
+	 METH_VARARGS|METH_KEYWORDS, NULL},
+	{"ptp", (PyCFunction)array_ptp,
+	 METH_VARARGS|METH_KEYWORDS, NULL},
+	{"put",	(PyCFunction)array_put,
+	 METH_VARARGS|METH_KEYWORDS, NULL},
+	{"putmask",	(PyCFunction)array_putmask,
+	 METH_VARARGS|METH_KEYWORDS, NULL},
 	{"ravel", (PyCFunction)array_ravel,
-	 METH_VARARGS, doc_ravel},
+	 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, doc_round},
+	 METH_VARARGS|METH_KEYWORDS, NULL},
+	{"searchsorted",  (PyCFunction)array_searchsorted,
+	 METH_VARARGS, NULL},
 	{"setflags", (PyCFunction)array_setflags,
-	 METH_VARARGS|METH_KEYWORDS, doc_setflags},
-	{"newbyteorder", (PyCFunction)array_newbyteorder,
-	 METH_VARARGS, doc_newbyteorder},
+	 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},
+	{"sum", (PyCFunction)array_sum,
+	 METH_VARARGS|METH_KEYWORDS, NULL},
+	{"swapaxes", (PyCFunction)array_swapaxes,
+	 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},
+	{"var", (PyCFunction)array_variance,
+	 METH_VARARGS|METH_KEYWORDS, NULL},
+	{"view",  (PyCFunction)array_view,
+	 METH_VARARGS, NULL},
         {NULL,		NULL}		/* sentinel */
 };
 



More information about the Numpy-svn mailing list