diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2008-08-27 03:17:51 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2008-08-27 03:17:51 +0000 |
commit | 88c8abb00f49bdabd3b336f0bf0a8efaf6887acd (patch) | |
tree | dc644b453fb7f9c225974aed6b4092d2a9c96a76 /numpy | |
parent | d4a1e796a44cbfaf087e8ce8feee61ca42447aee (diff) | |
download | numpy-88c8abb00f49bdabd3b336f0bf0a8efaf6887acd.tar.gz |
Revert r5698, r5699, and r5702 until build problems are fixed.
Fix ticket #878 differently.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/code_generators/generate_umath.py | 6 | ||||
-rw-r--r-- | numpy/core/src/arrayobject.c | 3 | ||||
-rw-r--r-- | numpy/core/src/umathmodule.c.src | 28 | ||||
-rw-r--r-- | numpy/lib/ufunclike.py | 31 |
4 files changed, 33 insertions, 35 deletions
diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py index 6a36d6add..ba57d53e0 100644 --- a/numpy/core/code_generators/generate_umath.py +++ b/numpy/core/code_generators/generate_umath.py @@ -476,12 +476,6 @@ defdict = { 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'), diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 586e7081a..ad3cbc4f2 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -3351,7 +3351,6 @@ typedef struct { *logical_and, *floor, *ceil, - *trunc, *maximum, *minimum, *rint, @@ -3409,7 +3408,6 @@ PyArray_SetNumericOps(PyObject *dict) SET(logical_and); SET(floor); SET(ceil); - SET(trunc); SET(maximum); SET(minimum); SET(rint); @@ -3460,7 +3458,6 @@ PyArray_GetNumericOps(void) GET(logical_and); GET(floor); GET(ceil); - GET(trunc); GET(maximum); GET(minimum); GET(rint); diff --git a/numpy/core/src/umathmodule.c.src b/numpy/core/src/umathmodule.c.src index 1517449a6..bef419bbd 100644 --- a/numpy/core/src/umathmodule.c.src +++ b/numpy/core/src/umathmodule.c.src @@ -302,10 +302,10 @@ static double hypot(double x, double y) } #endif - #ifndef HAVE_RINT +/* needs cleanup */ static double -rint (double x) +rint(double x) { double y, r; @@ -326,20 +326,24 @@ rint (double x) } #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 @@ longdouble radiansl(longdouble x) { /**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_@TYPE@_FUNCS diff --git a/numpy/lib/ufunclike.py b/numpy/lib/ufunclike.py index 2f5de2c37..5abdc9c8b 100644 --- a/numpy/lib/ufunclike.py +++ b/numpy/lib/ufunclike.py @@ -5,14 +5,17 @@ storing results in an output array. __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 @@ def isposinf(x, y=None): """ 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 @@ def isneginf(x, y=None): """ 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 @@ def log2(x, y=None): 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 |