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

numpy-svn at scipy.org numpy-svn at scipy.org
Wed Aug 23 18:39:47 CDT 2006


Author: cookedm
Date: 2006-08-23 18:39:42 -0500 (Wed, 23 Aug 2006)
New Revision: 3055

Modified:
   trunk/numpy/core/ma.py
   trunk/numpy/core/src/arraymethods.c
Log:
add .abs() as a method on the array object

Modified: trunk/numpy/core/ma.py
===================================================================
--- trunk/numpy/core/ma.py	2006-08-23 19:56:28 UTC (rev 3054)
+++ trunk/numpy/core/ma.py	2006-08-23 23:39:42 UTC (rev 3055)
@@ -2144,6 +2144,7 @@
     return MethodType(f, None, array)
 def not_implemented(*args, **kwds):
     raise NotImplementedError, "not yet implemented for numpy.ma arrays"
+array.abs = array.__abs__
 array.all = _m(alltrue)
 array.any = _m(sometrue)
 array.argmax = _m(argmax)

Modified: trunk/numpy/core/src/arraymethods.c
===================================================================
--- trunk/numpy/core/src/arraymethods.c	2006-08-23 19:56:28 UTC (rev 3054)
+++ trunk/numpy/core/src/arraymethods.c	2006-08-23 23:39:42 UTC (rev 3055)
@@ -252,6 +252,8 @@
 	return PyArray_Min(self, axis, out);
 }
 
+static char doc_abs[] = "a.abs() returns abs(a)";
+
 static char doc_swapaxes[] = "a.swapaxes(axis1, axis2)  returns new view with axes swapped.";
 
 static PyObject *
@@ -1806,6 +1808,8 @@
 	 METH_VARARGS|METH_KEYWORDS, doc_min},
 	{"ptp", (PyCFunction)array_ptp,
 	 METH_VARARGS|METH_KEYWORDS, doc_ptp},
+        {"abs", (PyCFunction)array_absolute,
+         METH_VARARGS, doc_abs},
 	{"mean", (PyCFunction)array_mean,
 	 METH_VARARGS|METH_KEYWORDS, doc_mean},
 	{"trace", (PyCFunction)array_trace,



More information about the Numpy-svn mailing list