[Numpy-svn] r5711 - in trunk/numpy: core/code_generators core/src lib

numpy-svn at scipy.org numpy-svn at scipy.org
Tue Aug 26 23:18:00 EDT 2008


Author: charris
Date: 2008-08-26 22:17:51 -0500 (Tue, 26 Aug 2008)
New Revision: 5711

Modified:
   trunk/numpy/core/code_generators/generate_umath.py
   trunk/numpy/core/src/arrayobject.c
   trunk/numpy/core/src/umathmodule.c.src
   trunk/numpy/lib/ufunclike.py
Log:
Revert r5698, r5699, and r5702 until build problems are fixed.
Fix ticket #878 differently.


Modified: trunk/numpy/core/code_generators/generate_umath.py
===================================================================
--- trunk/numpy/core/code_generators/generate_umath.py	2008-08-27 01:48:54 UTC (rev 5710)
+++ trunk/numpy/core/code_generators/generate_umath.py	2008-08-27 03:17:51 UTC (rev 5711)
@@ -476,12 +476,6 @@
           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-27 01:48:54 UTC (rev 5710)
+++ trunk/numpy/core/src/arrayobject.c	2008-08-27 03:17:51 UTC (rev 5711)
@@ -3351,7 +3351,6 @@
         *logical_and,
         *floor,
         *ceil,
-        *trunc,
         *maximum,
         *minimum,
         *rint,
@@ -3409,7 +3408,6 @@
     SET(logical_and);
     SET(floor);
     SET(ceil);
-    SET(trunc);
     SET(maximum);
     SET(minimum);
     SET(rint);
@@ -3460,7 +3458,6 @@
     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-27 01:48:54 UTC (rev 5710)
+++ trunk/numpy/core/src/umathmodule.c.src	2008-08-27 03:17:51 UTC (rev 5711)
@@ -302,10 +302,10 @@
 }
 #endif
 
-
 #ifndef HAVE_RINT
+/* needs cleanup */
 static double
-rint (double x)
+rint(double x)
 {
     double y, r;
 
@@ -326,20 +326,24 @@
 }
 #endif
 
+/*
+ * Comment out trunc definition until build problems are fixed.
+ */
+/*
 #ifndef HAVE_TRUNC
 static double
-trunc (double x)
+trunc(double x)
 {
-    double y, r;
-
     if (x < 0) {
-    	return - floor(-x);
-    } else {
-        return x;
+    	return -floor(-x);
     }
+    else {
+        return floor(x);
+    }
 
 }
 #endif
+*/
 
 
 
@@ -475,10 +479,10 @@
 
 /**begin repeat
 
-   #kind=(sin,cos,tan,sinh,cosh,tanh,fabs,floor,ceil,trunc,sqrt,log10,log,exp,asin,acos,atan,rint)*2#
-   #typ=longdouble*18, float*18#
-   #c=l*18,f*18#
-   #TYPE=LONGDOUBLE*18, FLOAT*18#
+   #kind=(sin,cos,tan,sinh,cosh,tanh,fabs,floor,ceil,sqrt,log10,log,exp,asin,acos,atan,rint)*2#
+   #typ=longdouble*17, float*17#
+   #c=l*17,f*17#
+   #TYPE=LONGDOUBLE*17, FLOAT*17#
 */
 
 #ifndef HAVE_ at TYPE@_FUNCS

Modified: trunk/numpy/lib/ufunclike.py
===================================================================
--- trunk/numpy/lib/ufunclike.py	2008-08-27 01:48:54 UTC (rev 5710)
+++ trunk/numpy/lib/ufunclike.py	2008-08-27 03:17:51 UTC (rev 5711)
@@ -5,14 +5,17 @@
 __all__ = ['fix', 'isneginf', 'isposinf', 'log2']
 
 import numpy.core.numeric as nx
-from numpy.core.numeric import asarray, empty, isinf, signbit, asanyarray
-import numpy.core.umath as umath
 
 def fix(x, y=None):
     """ Round x to nearest integer towards zero.
     """
-    # fix is now implemented in C, using the C99 trunc function.
-    return umath.trunc(x, y)
+    x = nx.asanyarray(x)
+    if y is None: 
+        y = nx.zeros_like(x)
+    y1 = nx.floor(x)
+    y2 = nx.ceil(x)
+    y[...] = nx.where(x >= 0, y1, y2)
+    return y 
 
 def isposinf(x, y=None):
     """
@@ -41,9 +44,9 @@
 
     """
     if y is None:
-        x = asarray(x)
-        y = empty(x.shape, dtype=nx.bool_)
-    umath.logical_and(isinf(x), ~signbit(x), y)
+        x = nx.asarray(x)
+        y = nx.empty(x.shape, dtype=nx.bool_)
+    nx.logical_and(nx.isinf(x), ~nx.signbit(x), y)
     return y
 
 def isneginf(x, y=None):
@@ -73,12 +76,12 @@
 
     """
     if y is None:
-        x = asarray(x)
-        y = empty(x.shape, dtype=nx.bool_)
-    umath.logical_and(isinf(x), signbit(x), y)
+        x = nx.asarray(x)
+        y = nx.empty(x.shape, dtype=nx.bool_)
+    nx.logical_and(nx.isinf(x), nx.signbit(x), y)
     return y
 
-_log2 = umath.log(2)
+_log2 = nx.log(2)
 def log2(x, y=None):
     """
     Return the base 2 logarithm.
@@ -107,10 +110,10 @@
     array([ NaN,   1.,   2.])
 
     """
-    x = asanyarray(x)
+    x = nx.asanyarray(x)
     if y is None:
-        y = umath.log(x)
+        y = nx.log(x)
     else:
-        umath.log(x, y)
+        nx.log(x, y)
     y /= _log2
     return y




More information about the Numpy-svn mailing list