[Numpy-svn] r6071 - in branches/visualstudio_manifest: . numpy/core/code_generators numpy/core/src numpy/ma numpy/random numpy/random/mtrand

numpy-svn@scip... numpy-svn@scip...
Mon Nov 17 06:49:51 CST 2008


Author: cdavid
Date: 2008-11-17 06:49:26 -0600 (Mon, 17 Nov 2008)
New Revision: 6071

Modified:
   branches/visualstudio_manifest/
   branches/visualstudio_manifest/numpy/core/code_generators/genapi.py
   branches/visualstudio_manifest/numpy/core/src/ufuncobject.c
   branches/visualstudio_manifest/numpy/core/src/umathmodule.c.src
   branches/visualstudio_manifest/numpy/ma/core.py
   branches/visualstudio_manifest/numpy/random/mtrand/randomkit.c
   branches/visualstudio_manifest/numpy/random/setup.py
Log:
Merged revisions 6051-6070 via svnmerge from 
http://svn.scipy.org/svn/numpy/trunk

........
  r6053 | charris | 2008-11-17 12:27:28 +0900 (Mon, 17 Nov 2008) | 1 line
  
  Test moving generic loops to umathmodule.
........
  r6054 | charris | 2008-11-17 12:27:46 +0900 (Mon, 17 Nov 2008) | 2 lines
  
  Add umathmodule.c.src to files scanned for ufunc api.
  This is preparation for splitting the umathmodule.c.src file.
........
  r6055 | pierregm | 2008-11-17 16:00:42 +0900 (Mon, 17 Nov 2008) | 1 line
  
  simplify MAError
........
  r6068 | cdavid | 2008-11-17 21:35:43 +0900 (Mon, 17 Nov 2008) | 1 line
  
  Simplify ftime workaround for python 2.6 under mingw: we only need to make _ftime an alias to _ftime64 when needed.
........
  r6069 | cdavid | 2008-11-17 21:36:17 +0900 (Mon, 17 Nov 2008) | 1 line
  
  Use a wrapper around _ftime to work around a mingw bug in msvc runtimes import libraries.
........
  r6070 | cdavid | 2008-11-17 21:41:13 +0900 (Mon, 17 Nov 2008) | 1 line
  
  Set __MSVCRT_VERSION__ to make _ftime64 visible from time.h header when we need to workaround mingw bug.
........



Property changes on: branches/visualstudio_manifest
___________________________________________________________________
Name: svnmerge-integrated
   - /branches/distutils-revamp:1-2752 /branches/multicore:1-3687 /trunk:1-6050
   + /branches/distutils-revamp:1-2752 /branches/multicore:1-3687 /trunk:1-6070

Modified: branches/visualstudio_manifest/numpy/core/code_generators/genapi.py
===================================================================
--- branches/visualstudio_manifest/numpy/core/code_generators/genapi.py	2008-11-17 12:41:13 UTC (rev 6070)
+++ branches/visualstudio_manifest/numpy/core/code_generators/genapi.py	2008-11-17 12:49:26 UTC (rev 6071)
@@ -18,6 +18,7 @@
              'multiarraymodule.c',
              'scalartypes.inc.src',
              'ufuncobject.c',
+             'umathmodule.c.src'
             ]
 THIS_DIR = os.path.dirname(__file__)
 API_FILES = [os.path.join(THIS_DIR, '..', 'src', a) for a in API_FILES]

Modified: branches/visualstudio_manifest/numpy/core/src/ufuncobject.c
===================================================================
--- branches/visualstudio_manifest/numpy/core/src/ufuncobject.c	2008-11-17 12:41:13 UTC (rev 6070)
+++ branches/visualstudio_manifest/numpy/core/src/ufuncobject.c	2008-11-17 12:49:26 UTC (rev 6071)
@@ -28,377 +28,8 @@
 #define USE_USE_DEFAULTS 1
 
 
-/******************************************************************************
- * Generic Real Floating Type Loops
- *****************************************************************************/
 
 
-typedef float floatUnaryFunc(float x);
-typedef double doubleUnaryFunc(double x);
-typedef longdouble longdoubleUnaryFunc(longdouble x);
-typedef float floatBinaryFunc(float x, float y);
-typedef double doubleBinaryFunc(double x, double y);
-typedef longdouble longdoubleBinaryFunc(longdouble x, longdouble y);
-
-
-/*UFUNC_API*/
-static void
-PyUFunc_f_f(char **args, intp *dimensions, intp *steps, void *func)
-{
-    floatUnaryFunc *f = (floatUnaryFunc *)func;
-    UNARY_LOOP {
-        const float in1 = *(float *)ip1;
-        *(float *)op1 = f(in1);
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_f_f_As_d_d(char **args, intp *dimensions, intp *steps, void *func)
-{
-    doubleUnaryFunc *f = (doubleUnaryFunc *)func;
-    UNARY_LOOP {
-        const float in1 = *(float *)ip1;
-        *(float *)op1 = (float)f((double)in1);
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_ff_f(char **args, intp *dimensions, intp *steps, void *func)
-{
-    floatBinaryFunc *f = (floatBinaryFunc *)func;
-    BINARY_LOOP {
-        float in1 = *(float *)ip1;
-        float in2 = *(float *)ip2;
-        *(float *)op1 = f(in1, in2);
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)
-{
-    doubleBinaryFunc *f = (doubleBinaryFunc *)func;
-    BINARY_LOOP {
-        float in1 = *(float *)ip1;
-        float in2 = *(float *)ip2;
-        *(float *)op1 = (double)f((double)in1, (double)in2);
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_d_d(char **args, intp *dimensions, intp *steps, void *func)
-{
-    doubleUnaryFunc *f = (doubleUnaryFunc *)func;
-    UNARY_LOOP {
-        double in1 = *(double *)ip1;
-        *(double *)op1 = f(in1);
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_dd_d(char **args, intp *dimensions, intp *steps, void *func)
-{
-    doubleBinaryFunc *f = (doubleBinaryFunc *)func;
-    BINARY_LOOP {
-        double in1 = *(double *)ip1;
-        double in2 = *(double *)ip2;
-        *(double *)op1 = f(in1, in2);
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_g_g(char **args, intp *dimensions, intp *steps, void *func)
-{
-    longdoubleUnaryFunc *f = (longdoubleUnaryFunc *)func;
-    UNARY_LOOP {
-        longdouble in1 = *(longdouble *)ip1;
-        *(longdouble *)op1 = f(in1);
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_gg_g(char **args, intp *dimensions, intp *steps, void *func)
-{
-    longdoubleBinaryFunc *f = (longdoubleBinaryFunc *)func;
-    BINARY_LOOP {
-        longdouble in1 = *(longdouble *)ip1;
-        longdouble in2 = *(longdouble *)ip2;
-        *(longdouble *)op1 = f(in1, in2);
-    }
-}
-
-
-
-/******************************************************************************
- * Generic Complex Floating Type Loops
- *****************************************************************************/
-
-
-typedef void cdoubleUnaryFunc(cdouble *x, cdouble *r);
-typedef void cfloatUnaryFunc(cfloat *x, cfloat *r);
-typedef void clongdoubleUnaryFunc(clongdouble *x, clongdouble *r);
-typedef void cdoubleBinaryFunc(cdouble *x, cdouble *y, cdouble *r);
-typedef void cfloatBinaryFunc(cfloat *x, cfloat *y, cfloat *r);
-typedef void clongdoubleBinaryFunc(clongdouble *x, clongdouble *y,
-                                   clongdouble *r);
-
-/*UFUNC_API*/
-static void
-PyUFunc_F_F(char **args, intp *dimensions, intp *steps, void *func)
-{
-    cfloatUnaryFunc *f = (cfloatUnaryFunc *)func;
-    UNARY_LOOP {
-        cfloat in1 = *(cfloat *)ip1;
-        cfloat *out = (cfloat *)op1;
-        f(&in1, out);
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_F_F_As_D_D(char **args, intp *dimensions, intp *steps, void *func)
-{
-    cdoubleUnaryFunc *f = (cdoubleUnaryFunc *)func;
-    UNARY_LOOP {
-        const float *in1 = (float *)ip1;
-        cdouble tmp = {(double)(in1[0]),(double)in1[1]};
-        cdouble out;
-        f(&tmp, &out);
-        ((float *)op1)[0] = (float)out.real;
-        ((float *)op1)[1] = (float)out.imag;
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_FF_F(char **args, intp *dimensions, intp *steps, void *func)
-{
-    cfloatBinaryFunc *f = (cfloatBinaryFunc *)func;
-    BINARY_LOOP {
-        cfloat in1 = *(cfloat *)ip1;
-        cfloat in2 = *(cfloat *)ip2;
-        cfloat *out = (cfloat *)op1;
-        f(&in1, &in2, out);
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_FF_F_As_DD_D(char **args, intp *dimensions, intp *steps, void *func)
-{
-    cdoubleBinaryFunc *f = (cdoubleBinaryFunc *)func;
-    BINARY_LOOP {
-        const float *in1 = (float *)ip1;
-        const float *in2 = (float *)ip2;
-        cdouble tmp1 = {(double)(in1[0]),(double)in1[1]};
-        cdouble tmp2 = {(double)(in2[0]),(double)in2[1]};
-        cdouble out;
-        f(&tmp1, &tmp2, &out);
-        ((float *)op1)[0] = (float)out.real;
-        ((float *)op1)[1] = (float)out.imag;
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_D_D(char **args, intp *dimensions, intp *steps, void *func)
-{
-    cdoubleUnaryFunc *f = (cdoubleUnaryFunc *)func;
-    UNARY_LOOP {
-        cdouble in1 = *(cdouble *)ip1;
-        cdouble *out = (cdouble *)op1;
-        f(&in1, out);
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_DD_D(char **args, intp *dimensions, intp *steps, void *func)
-{
-    cdoubleBinaryFunc *f = (cdoubleBinaryFunc *)func;
-    BINARY_LOOP {
-        cdouble in1 = *(cdouble *)ip1;
-        cdouble in2 = *(cdouble *)ip2;
-        cdouble *out = (cdouble *)op1;
-        f(&in1, &in2, out);
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_G_G(char **args, intp *dimensions, intp *steps, void *func)
-{
-    clongdoubleUnaryFunc *f = (clongdoubleUnaryFunc *)func;
-    UNARY_LOOP {
-        clongdouble in1 = *(clongdouble *)ip1;
-        clongdouble *out = (clongdouble *)op1;
-        f(&in1, out);
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_GG_G(char **args, intp *dimensions, intp *steps, void *func)
-{
-    clongdoubleBinaryFunc *f = (clongdoubleBinaryFunc *)func;
-    BINARY_LOOP {
-        clongdouble in1 = *(clongdouble *)ip1;
-        clongdouble in2 = *(clongdouble *)ip2;
-        clongdouble *out = (clongdouble *)op1;
-        f(&in1, &in2, out);
-    }
-}
-
-
-/******************************************************************************
- * Generic Object Type Loops
- *****************************************************************************/
-
-/*UFUNC_API*/
-static void
-PyUFunc_O_O(char **args, intp *dimensions, intp *steps, void *func)
-{
-    unaryfunc f = (unaryfunc)func;
-    UNARY_LOOP {
-        PyObject *in1 = *(PyObject **)ip1;
-        PyObject **out = (PyObject **)op1;
-        PyObject *ret = f(in1);
-        if ((ret == NULL) || PyErr_Occurred()) {
-            return;
-        }
-        Py_XDECREF(*out);
-        *out = ret;
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_O_O_method(char **args, intp *dimensions, intp *steps, void *func)
-{
-    char *meth = (char *)func;
-    UNARY_LOOP {
-        PyObject *in1 = *(PyObject **)ip1;
-        PyObject **out = (PyObject **)op1;
-        PyObject *ret = PyObject_CallMethod(in1, meth, NULL);
-        if (ret == NULL) {
-            return;
-        }
-        Py_XDECREF(*out);
-        *out = ret;
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_OO_O(char **args, intp *dimensions, intp *steps, void *func)
-{
-    binaryfunc f = (binaryfunc)func;
-    BINARY_LOOP {
-        PyObject *in1 = *(PyObject **)ip1;
-        PyObject *in2 = *(PyObject **)ip2;
-        PyObject **out = (PyObject **)op1;
-        PyObject *ret = f(in1, in2);
-        if (PyErr_Occurred()) {
-            return;
-        }
-        Py_XDECREF(*out);
-        *out = ret;
-    }
-}
-
-/*UFUNC_API*/
-static void
-PyUFunc_OO_O_method(char **args, intp *dimensions, intp *steps, void *func)
-{
-    char *meth = (char *)func;
-    BINARY_LOOP {
-        PyObject *in1 = *(PyObject **)ip1;
-        PyObject *in2 = *(PyObject **)ip2;
-        PyObject **out = (PyObject **)op1;
-        PyObject *ret = PyObject_CallMethod(in1, meth, "(O)", in2);
-        if (ret == NULL) {
-            return;
-        }
-        Py_XDECREF(*out);
-        *out = ret;
-    }
-}
-
-/*
- * A general-purpose ufunc that deals with general-purpose Python callable.
- * func is a structure with nin, nout, and a Python callable function
- */
-
-/*UFUNC_API*/
-static void
-PyUFunc_On_Om(char **args, intp *dimensions, intp *steps, void *func)
-{
-    intp n =  dimensions[0];
-    PyUFunc_PyFuncData *data = (PyUFunc_PyFuncData *)func;
-    int nin = data->nin;
-    int nout = data->nout;
-    PyObject *tocall = data->callable;
-    char *ptrs[NPY_MAXARGS];
-    PyObject *arglist, *result;
-    PyObject *in, **op;
-    intp i, j, ntot;
-
-    ntot = nin+nout;
-
-    for(j = 0; j < ntot; j++) {
-        ptrs[j] = args[j];
-    }
-    for(i = 0; i < n; i++) {
-        arglist = PyTuple_New(nin);
-        if (arglist == NULL) {
-            return;
-        }
-        for(j = 0; j < nin; j++) {
-            in = *((PyObject **)ptrs[j]);
-            if (in == NULL) {
-                Py_DECREF(arglist);
-                return;
-            }
-            PyTuple_SET_ITEM(arglist, j, in);
-            Py_INCREF(in);
-        }
-        result = PyEval_CallObject(tocall, arglist);
-        Py_DECREF(arglist);
-        if (result == NULL) {
-            return;
-        }
-        if PyTuple_Check(result) {
-            if (nout != PyTuple_Size(result)) {
-                Py_DECREF(result);
-                return;
-            }
-            for(j = 0; j < nout; j++) {
-                op = (PyObject **)ptrs[j+nin];
-                Py_XDECREF(*op);
-                *op = PyTuple_GET_ITEM(result, j);
-                Py_INCREF(*op);
-            }
-            Py_DECREF(result);
-        }
-        else {
-            op = (PyObject **)ptrs[nin];
-            Py_XDECREF(*op);
-            *op = result;
-        }
-        for(j = 0; j < ntot; j++) {
-            ptrs[j] += steps[j];
-        }
-    }
-}
-
-
-
 /* ---------------------------------------------------------------- */
 
 

Modified: branches/visualstudio_manifest/numpy/core/src/umathmodule.c.src
===================================================================
--- branches/visualstudio_manifest/numpy/core/src/umathmodule.c.src	2008-11-17 12:41:13 UTC (rev 6070)
+++ branches/visualstudio_manifest/numpy/core/src/umathmodule.c.src	2008-11-17 12:49:26 UTC (rev 6071)
@@ -606,7 +606,376 @@
     intp i;\
     for(i = 0; i < n; i++, ip1 += is1, ip2 += is2, op1 += os1, op2 += os2)
 
+/******************************************************************************
+ **                          GENERIC FLOAT LOOPS                             **
+ *****************************************************************************/
+
+
+typedef float floatUnaryFunc(float x);
+typedef double doubleUnaryFunc(double x);
+typedef longdouble longdoubleUnaryFunc(longdouble x);
+typedef float floatBinaryFunc(float x, float y);
+typedef double doubleBinaryFunc(double x, double y);
+typedef longdouble longdoubleBinaryFunc(longdouble x, longdouble y);
+
+
+/*UFUNC_API*/
+static void
+PyUFunc_f_f(char **args, intp *dimensions, intp *steps, void *func)
+{
+    floatUnaryFunc *f = (floatUnaryFunc *)func;
+    UNARY_LOOP {
+        const float in1 = *(float *)ip1;
+        *(float *)op1 = f(in1);
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_f_f_As_d_d(char **args, intp *dimensions, intp *steps, void *func)
+{
+    doubleUnaryFunc *f = (doubleUnaryFunc *)func;
+    UNARY_LOOP {
+        const float in1 = *(float *)ip1;
+        *(float *)op1 = (float)f((double)in1);
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_ff_f(char **args, intp *dimensions, intp *steps, void *func)
+{
+    floatBinaryFunc *f = (floatBinaryFunc *)func;
+    BINARY_LOOP {
+        float in1 = *(float *)ip1;
+        float in2 = *(float *)ip2;
+        *(float *)op1 = f(in1, in2);
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)
+{
+    doubleBinaryFunc *f = (doubleBinaryFunc *)func;
+    BINARY_LOOP {
+        float in1 = *(float *)ip1;
+        float in2 = *(float *)ip2;
+        *(float *)op1 = (double)f((double)in1, (double)in2);
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_d_d(char **args, intp *dimensions, intp *steps, void *func)
+{
+    doubleUnaryFunc *f = (doubleUnaryFunc *)func;
+    UNARY_LOOP {
+        double in1 = *(double *)ip1;
+        *(double *)op1 = f(in1);
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_dd_d(char **args, intp *dimensions, intp *steps, void *func)
+{
+    doubleBinaryFunc *f = (doubleBinaryFunc *)func;
+    BINARY_LOOP {
+        double in1 = *(double *)ip1;
+        double in2 = *(double *)ip2;
+        *(double *)op1 = f(in1, in2);
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_g_g(char **args, intp *dimensions, intp *steps, void *func)
+{
+    longdoubleUnaryFunc *f = (longdoubleUnaryFunc *)func;
+    UNARY_LOOP {
+        longdouble in1 = *(longdouble *)ip1;
+        *(longdouble *)op1 = f(in1);
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_gg_g(char **args, intp *dimensions, intp *steps, void *func)
+{
+    longdoubleBinaryFunc *f = (longdoubleBinaryFunc *)func;
+    BINARY_LOOP {
+        longdouble in1 = *(longdouble *)ip1;
+        longdouble in2 = *(longdouble *)ip2;
+        *(longdouble *)op1 = f(in1, in2);
+    }
+}
+
+
+
+/******************************************************************************
+ **                          GENERIC COMPLEX LOOPS                           **
+ *****************************************************************************/
+
+
+typedef void cdoubleUnaryFunc(cdouble *x, cdouble *r);
+typedef void cfloatUnaryFunc(cfloat *x, cfloat *r);
+typedef void clongdoubleUnaryFunc(clongdouble *x, clongdouble *r);
+typedef void cdoubleBinaryFunc(cdouble *x, cdouble *y, cdouble *r);
+typedef void cfloatBinaryFunc(cfloat *x, cfloat *y, cfloat *r);
+typedef void clongdoubleBinaryFunc(clongdouble *x, clongdouble *y,
+                                   clongdouble *r);
+
+/*UFUNC_API*/
+static void
+PyUFunc_F_F(char **args, intp *dimensions, intp *steps, void *func)
+{
+    cfloatUnaryFunc *f = (cfloatUnaryFunc *)func;
+    UNARY_LOOP {
+        cfloat in1 = *(cfloat *)ip1;
+        cfloat *out = (cfloat *)op1;
+        f(&in1, out);
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_F_F_As_D_D(char **args, intp *dimensions, intp *steps, void *func)
+{
+    cdoubleUnaryFunc *f = (cdoubleUnaryFunc *)func;
+    UNARY_LOOP {
+        const float *in1 = (float *)ip1;
+        cdouble tmp = {(double)(in1[0]),(double)in1[1]};
+        cdouble out;
+        f(&tmp, &out);
+        ((float *)op1)[0] = (float)out.real;
+        ((float *)op1)[1] = (float)out.imag;
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_FF_F(char **args, intp *dimensions, intp *steps, void *func)
+{
+    cfloatBinaryFunc *f = (cfloatBinaryFunc *)func;
+    BINARY_LOOP {
+        cfloat in1 = *(cfloat *)ip1;
+        cfloat in2 = *(cfloat *)ip2;
+        cfloat *out = (cfloat *)op1;
+        f(&in1, &in2, out);
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_FF_F_As_DD_D(char **args, intp *dimensions, intp *steps, void *func)
+{
+    cdoubleBinaryFunc *f = (cdoubleBinaryFunc *)func;
+    BINARY_LOOP {
+        const float *in1 = (float *)ip1;
+        const float *in2 = (float *)ip2;
+        cdouble tmp1 = {(double)(in1[0]),(double)in1[1]};
+        cdouble tmp2 = {(double)(in2[0]),(double)in2[1]};
+        cdouble out;
+        f(&tmp1, &tmp2, &out);
+        ((float *)op1)[0] = (float)out.real;
+        ((float *)op1)[1] = (float)out.imag;
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_D_D(char **args, intp *dimensions, intp *steps, void *func)
+{
+    cdoubleUnaryFunc *f = (cdoubleUnaryFunc *)func;
+    UNARY_LOOP {
+        cdouble in1 = *(cdouble *)ip1;
+        cdouble *out = (cdouble *)op1;
+        f(&in1, out);
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_DD_D(char **args, intp *dimensions, intp *steps, void *func)
+{
+    cdoubleBinaryFunc *f = (cdoubleBinaryFunc *)func;
+    BINARY_LOOP {
+        cdouble in1 = *(cdouble *)ip1;
+        cdouble in2 = *(cdouble *)ip2;
+        cdouble *out = (cdouble *)op1;
+        f(&in1, &in2, out);
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_G_G(char **args, intp *dimensions, intp *steps, void *func)
+{
+    clongdoubleUnaryFunc *f = (clongdoubleUnaryFunc *)func;
+    UNARY_LOOP {
+        clongdouble in1 = *(clongdouble *)ip1;
+        clongdouble *out = (clongdouble *)op1;
+        f(&in1, out);
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_GG_G(char **args, intp *dimensions, intp *steps, void *func)
+{
+    clongdoubleBinaryFunc *f = (clongdoubleBinaryFunc *)func;
+    BINARY_LOOP {
+        clongdouble in1 = *(clongdouble *)ip1;
+        clongdouble in2 = *(clongdouble *)ip2;
+        clongdouble *out = (clongdouble *)op1;
+        f(&in1, &in2, out);
+    }
+}
+
+
+/******************************************************************************
+ **                         GENERIC OBJECT lOOPS                             **
+ *****************************************************************************/
+
+/*UFUNC_API*/
+static void
+PyUFunc_O_O(char **args, intp *dimensions, intp *steps, void *func)
+{
+    unaryfunc f = (unaryfunc)func;
+    UNARY_LOOP {
+        PyObject *in1 = *(PyObject **)ip1;
+        PyObject **out = (PyObject **)op1;
+        PyObject *ret = f(in1);
+        if ((ret == NULL) || PyErr_Occurred()) {
+            return;
+        }
+        Py_XDECREF(*out);
+        *out = ret;
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_O_O_method(char **args, intp *dimensions, intp *steps, void *func)
+{
+    char *meth = (char *)func;
+    UNARY_LOOP {
+        PyObject *in1 = *(PyObject **)ip1;
+        PyObject **out = (PyObject **)op1;
+        PyObject *ret = PyObject_CallMethod(in1, meth, NULL);
+        if (ret == NULL) {
+            return;
+        }
+        Py_XDECREF(*out);
+        *out = ret;
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_OO_O(char **args, intp *dimensions, intp *steps, void *func)
+{
+    binaryfunc f = (binaryfunc)func;
+    BINARY_LOOP {
+        PyObject *in1 = *(PyObject **)ip1;
+        PyObject *in2 = *(PyObject **)ip2;
+        PyObject **out = (PyObject **)op1;
+        PyObject *ret = f(in1, in2);
+        if (PyErr_Occurred()) {
+            return;
+        }
+        Py_XDECREF(*out);
+        *out = ret;
+    }
+}
+
+/*UFUNC_API*/
+static void
+PyUFunc_OO_O_method(char **args, intp *dimensions, intp *steps, void *func)
+{
+    char *meth = (char *)func;
+    BINARY_LOOP {
+        PyObject *in1 = *(PyObject **)ip1;
+        PyObject *in2 = *(PyObject **)ip2;
+        PyObject **out = (PyObject **)op1;
+        PyObject *ret = PyObject_CallMethod(in1, meth, "(O)", in2);
+        if (ret == NULL) {
+            return;
+        }
+        Py_XDECREF(*out);
+        *out = ret;
+    }
+}
+
 /*
+ * A general-purpose ufunc that deals with general-purpose Python callable.
+ * func is a structure with nin, nout, and a Python callable function
+ */
+
+/*UFUNC_API*/
+static void
+PyUFunc_On_Om(char **args, intp *dimensions, intp *steps, void *func)
+{
+    intp n =  dimensions[0];
+    PyUFunc_PyFuncData *data = (PyUFunc_PyFuncData *)func;
+    int nin = data->nin;
+    int nout = data->nout;
+    PyObject *tocall = data->callable;
+    char *ptrs[NPY_MAXARGS];
+    PyObject *arglist, *result;
+    PyObject *in, **op;
+    intp i, j, ntot;
+
+    ntot = nin+nout;
+
+    for(j = 0; j < ntot; j++) {
+        ptrs[j] = args[j];
+    }
+    for(i = 0; i < n; i++) {
+        arglist = PyTuple_New(nin);
+        if (arglist == NULL) {
+            return;
+        }
+        for(j = 0; j < nin; j++) {
+            in = *((PyObject **)ptrs[j]);
+            if (in == NULL) {
+                Py_DECREF(arglist);
+                return;
+            }
+            PyTuple_SET_ITEM(arglist, j, in);
+            Py_INCREF(in);
+        }
+        result = PyEval_CallObject(tocall, arglist);
+        Py_DECREF(arglist);
+        if (result == NULL) {
+            return;
+        }
+        if PyTuple_Check(result) {
+            if (nout != PyTuple_Size(result)) {
+                Py_DECREF(result);
+                return;
+            }
+            for(j = 0; j < nout; j++) {
+                op = (PyObject **)ptrs[j+nin];
+                Py_XDECREF(*op);
+                *op = PyTuple_GET_ITEM(result, j);
+                Py_INCREF(*op);
+            }
+            Py_DECREF(result);
+        }
+        else {
+            op = (PyObject **)ptrs[nin];
+            Py_XDECREF(*op);
+            *op = result;
+        }
+        for(j = 0; j < ntot; j++) {
+            ptrs[j] += steps[j];
+        }
+    }
+}
+
+/*
  *****************************************************************************
  **                             BOOLEAN LOOPS                               **
  *****************************************************************************

Modified: branches/visualstudio_manifest/numpy/ma/core.py
===================================================================
--- branches/visualstudio_manifest/numpy/ma/core.py	2008-11-17 12:41:13 UTC (rev 6070)
+++ branches/visualstudio_manifest/numpy/ma/core.py	2008-11-17 12:49:26 UTC (rev 6071)
@@ -95,15 +95,9 @@
 #####--------------------------------------------------------------------------
 class MAError(Exception):
     "Class for MA related errors."
-    def __init__ (self, args=None):
-        "Creates an exception."
-        Exception.__init__(self, args)
-        self.args = args
-    def __str__(self):
-        "Calculates the string representation."
-        return str(self.args)
-    __repr__ = __str__
+    pass
 
+
 #####--------------------------------------------------------------------------
 #---- --- Filling options ---
 #####--------------------------------------------------------------------------
@@ -4102,8 +4096,27 @@
 
 #..............................................................................
 def asarray(a, dtype=None):
-    """asarray(data, dtype) = array(data, dtype, copy=0, subok=0)
-
+    """
+    Convert the input to a masked array.
+    
+    Parameters
+    ----------
+    a : array_like
+        Input data, in any form that can be converted to an array.  This
+        includes lists, lists of tuples, tuples, tuples of tuples, tuples
+        of lists and ndarrays.
+    dtype : data-type, optional
+        By default, the data-type is inferred from the input data.
+    order : {'C', 'F'}, optional
+        Whether to use row-major ('C') or column-major ('FORTRAN') memory
+        representation.  Defaults to 'C'.
+    
+    Returns
+    -------
+    out : ndarray
+        MaskedArray interpretation of `a`.  No copy is performed if the input
+        is already an ndarray.  If `a` is a subclass of ndarray, a base
+        class ndarray is returned.
     Return a as a MaskedArray object of the given dtype.
     If dtype is not given or None, is is set to the dtype of a.
     No copy is performed if a is already an array.

Modified: branches/visualstudio_manifest/numpy/random/mtrand/randomkit.c
===================================================================
--- branches/visualstudio_manifest/numpy/random/mtrand/randomkit.c	2008-11-17 12:41:13 UTC (rev 6070)
+++ branches/visualstudio_manifest/numpy/random/mtrand/randomkit.c	2008-11-17 12:49:26 UTC (rev 6071)
@@ -75,6 +75,18 @@
 
 #ifdef _WIN32
 /* Windows */
+#ifdef NPY_NEEDS_MINGW_TIME_WORKAROUND
+/* FIXME: ideally, we should set this to the real version of MSVCRT. We need
+ * something higher than 0x601 to enable _ftime64 and co */
+#define __MSVCRT_VERSION__ 0x0700
+/* mingw msvcr lib import wrongly export _ftime, which does not exist in the
+ * actual msvc runtime for version >= 8; we make it an alist to _ftime64, which
+ * is available in those versions of the runtime and should be ABI compatible
+ */
+#define _FTIME(x) _ftime64((x))
+#else
+#define _FTIME(x) _ftime((x))
+#endif
 #include <time.h>
 #include <sys/timeb.h>
 #ifndef RK_NO_WINCRYPT
@@ -169,7 +181,7 @@
 	rk_seed(rk_hash(getpid()) ^ rk_hash(tv.tv_sec) ^ rk_hash(tv.tv_usec)
 		^ rk_hash(clock()), state);
 #else
-	_ftime(&tv);
+	_FTIME(&tv);
 	rk_seed(rk_hash(tv.time) ^ rk_hash(tv.millitm) ^ rk_hash(clock()), state);
 #endif
 

Modified: branches/visualstudio_manifest/numpy/random/setup.py
===================================================================
--- branches/visualstudio_manifest/numpy/random/setup.py	2008-11-17 12:41:13 UTC (rev 6070)
+++ branches/visualstudio_manifest/numpy/random/setup.py	2008-11-17 12:49:26 UTC (rev 6071)
@@ -2,20 +2,17 @@
 import os
 import sys
 from distutils.dep_util import newer
-from numpy.distutils.misc_util import msvc_runtime_library
+from distutils.msvccompiler import get_build_version as get_msvc_build_version
 
-def msvc_version():
-    """Return the msvc version used to build the running python, None if not
-    built with MSVC."""
-    msc_pos = sys.version.find('MSC v.')
-    if msc_pos != -1:
-        return sys.version[msc_pos+6:msc_pos+10]
-    return None
+def needs_mingw_ftime_workaround(config):
+    # We need the mingw workaround for _ftime if the msvc runtime version is
+    # 7.1 or above and we build with mingw
+    if config.compiler.compiler_type == 'mingw32':
+        msver = get_msvc_build_version()
+        if msver and msver > 7:
+            return True
 
-def msvcrt_to_hex(msvc):
-    major = msvc / 10
-    minor = msvc - major * 10
-    return hex(major * 256 + minor)
+    return False
 
 def configuration(parent_package='',top_path=None):
     from numpy.distutils.misc_util import Configuration, get_mathlibs
@@ -37,16 +34,9 @@
         if not os.path.exists(dir):
             os.makedirs(dir)
 
-        msv = msvc_version()
-        if msv and msv >= 1400:
-            msvcrt = msvc_runtime_library()
-            if msvcrt is None:
-                raise ValueError("Discrepancy between " \
-                                 "msvc_runtime_library " \
-                                 "and our msvc detection scheme ?")
-            hmsvc = msvcrt_to_hex(int(msvcrt[5:]))
+        config_cmd = config.get_config_cmd()
+        if needs_mingw_ftime_workaround(config_cmd):
             defs.append("NPY_NEEDS_MINGW_TIME_WORKAROUND")
-            defs.append(("NPY_MSVCRT_VERSION", str(hmsvc)))
 
         if newer(__file__, target):
             target_f = open(target, 'a')



More information about the Numpy-svn mailing list