[Numpy-svn] r5699 - in trunk/numpy/core: code_generators src
numpy-svn at scipy.org
numpy-svn at scipy.org
Mon Aug 25 18:05:46 EDT 2008
Author: cdavid
Date: 2008-08-25 17:05:29 -0500 (Mon, 25 Aug 2008)
New Revision: 5699
Modified:
trunk/numpy/core/code_generators/docstrings.py
trunk/numpy/core/code_generators/generate_umath.py
trunk/numpy/core/src/arrayobject.c
trunk/numpy/core/src/umathmodule.c.src
Log:
Add a trunc function in umath module.
Modified: trunk/numpy/core/code_generators/docstrings.py
===================================================================
--- trunk/numpy/core/code_generators/docstrings.py 2008-08-25 22:05:21 UTC (rev 5698)
+++ trunk/numpy/core/code_generators/docstrings.py 2008-08-25 22:05:29 UTC (rev 5699)
@@ -689,6 +689,31 @@
""")
+add_newdoc('numpy.core.umath', 'trunc',
+ """
+ Return the truncated value of the input, element-wise.
+
+ The truncated value of the scalar `x` is the nearest integer `i`, such
+ that i is not larger than x amplitude
+
+ Parameters
+ ----------
+ x : array_like
+ Input data.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The truncated value of each element in `x`.
+
+ Examples
+ --------
+ >>> a = np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])
+ >>> np.ceil(a)
+ array([-1., -1., -0., 0., 1., 1., 2.])
+
+ """)
+
add_newdoc('numpy.core.umath', 'conjugate',
"""
Return the complex conjugate, element-wise.
Modified: trunk/numpy/core/code_generators/generate_umath.py
===================================================================
--- trunk/numpy/core/code_generators/generate_umath.py 2008-08-25 22:05:21 UTC (rev 5698)
+++ trunk/numpy/core/code_generators/generate_umath.py 2008-08-25 22:05:29 UTC (rev 5699)
@@ -476,6 +476,12 @@
TD(flts, f='ceil'),
TD(M, f='ceil'),
),
+'trunc' :
+ Ufunc(1, 1, None,
+ docstrings.get('numpy.core.umath.trunc'),
+ TD(flts, f='trunc'),
+ TD(M, f='trunc'),
+ ),
'fabs' :
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.fabs'),
Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c 2008-08-25 22:05:21 UTC (rev 5698)
+++ trunk/numpy/core/src/arrayobject.c 2008-08-25 22:05:29 UTC (rev 5699)
@@ -3351,6 +3351,7 @@
*logical_and,
*floor,
*ceil,
+ *trunc,
*maximum,
*minimum,
*rint,
@@ -3408,6 +3409,7 @@
SET(logical_and);
SET(floor);
SET(ceil);
+ SET(trunc);
SET(maximum);
SET(minimum);
SET(rint);
@@ -3458,6 +3460,7 @@
GET(logical_and);
GET(floor);
GET(ceil);
+ GET(trunc);
GET(maximum);
GET(minimum);
GET(rint);
Modified: trunk/numpy/core/src/umathmodule.c.src
===================================================================
--- trunk/numpy/core/src/umathmodule.c.src 2008-08-25 22:05:21 UTC (rev 5698)
+++ trunk/numpy/core/src/umathmodule.c.src 2008-08-25 22:05:29 UTC (rev 5699)
@@ -333,7 +333,7 @@
double y, r;
if (x < 0) {
- return - floor(-x);
+ return - floor(-x);
} else {
return x;
}
More information about the Numpy-svn
mailing list