[Numpy-svn] r3748 - in branches/multicore: . numpy/core numpy/core/code_generators numpy/core/include/numpy numpy/core/src numpy/core/tests numpy/distutils numpy/distutils/command numpy/distutils/tests numpy/distutils/tests/f2py_ext numpy/distutils/tests/f2py_f90_ext numpy/distutils/tests/gen_ext numpy/distutils/tests/pyrex_ext numpy/distutils/tests/swig_ext numpy/f2py/tests/array_from_pyobj numpy/fft numpy/lib numpy/linalg numpy/numarray numpy/oldnumeric numpy/random numpy/testing
numpy-svn at scipy.org
numpy-svn at scipy.org
Fri May 11 17:49:18 EDT 2007
Author: eric
Date: 2007-05-11 16:49:03 -0500 (Fri, 11 May 2007)
New Revision: 3748
Modified:
branches/multicore/
branches/multicore/numpy/core/code_generators/genapi.py
branches/multicore/numpy/core/include/numpy/ndarrayobject.h
branches/multicore/numpy/core/records.py
branches/multicore/numpy/core/setup.py
branches/multicore/numpy/core/src/arrayobject.c
branches/multicore/numpy/core/src/arraytypes.inc.src
branches/multicore/numpy/core/src/multiarraymodule.c
branches/multicore/numpy/core/tests/test_multiarray.py
branches/multicore/numpy/distutils/command/build_src.py
branches/multicore/numpy/distutils/core.py
branches/multicore/numpy/distutils/misc_util.py
branches/multicore/numpy/distutils/setup.py
branches/multicore/numpy/distutils/system_info.py
branches/multicore/numpy/distutils/tests/f2py_ext/setup.py
branches/multicore/numpy/distutils/tests/f2py_f90_ext/setup.py
branches/multicore/numpy/distutils/tests/gen_ext/setup.py
branches/multicore/numpy/distutils/tests/pyrex_ext/setup.py
branches/multicore/numpy/distutils/tests/setup.py
branches/multicore/numpy/distutils/tests/swig_ext/setup.py
branches/multicore/numpy/f2py/tests/array_from_pyobj/setup.py
branches/multicore/numpy/fft/setup.py
branches/multicore/numpy/lib/setup.py
branches/multicore/numpy/linalg/setup.py
branches/multicore/numpy/numarray/setup.py
branches/multicore/numpy/oldnumeric/mlab.py
branches/multicore/numpy/oldnumeric/setup.py
branches/multicore/numpy/random/setup.py
branches/multicore/numpy/testing/numpytest.py
branches/multicore/numpy/testing/setup.py
branches/multicore/numpy/testing/utils.py
Log:
Merged revisions 3734-3747 via svnmerge from
http://svn.scipy.org/svn/numpy/trunk
........
r3735 | oliphant | 2007-05-03 23:08:15 -0500 (Thu, 03 May 2007) | 1 line
Fix compatibility layer definition of std
........
r3736 | rkern | 2007-05-04 16:17:20 -0500 (Fri, 04 May 2007) | 1 line
assert_approx_equal used significant digit more than requested.
........
r3737 | oliphant | 2007-05-09 11:27:06 -0500 (Wed, 09 May 2007) | 1 line
Change recarray attribute getting to return a view using the class instead of pure recarray when fields are present.
........
r3738 | cookedm | 2007-05-10 12:23:52 -0500 (Thu, 10 May 2007) | 2 lines
Add docstrings to numpy/core/code_generators/genapi.py
........
r3739 | cookedm | 2007-05-10 12:24:44 -0500 (Thu, 10 May 2007) | 2 lines
Better warning when using ScipyTest
........
r3740 | cookedm | 2007-05-10 12:26:20 -0500 (Thu, 10 May 2007) | 2 lines
Use a try/finally instead of try/except Exception for cleanup in numpy/distutils/core.py
........
r3741 | cookedm | 2007-05-10 13:14:29 -0500 (Thu, 10 May 2007) | 10 lines
Improvement of separator handling for fromstring and fromfile.
* fromstring and fromfile should behave identically on text.
* added more test cases for fromstring
* the dtype gets passed to the C code doing the type-specific string
conversions. We don't use it, but someone making their own dtype could.
* separator handling for fromfile is moved out of the type-specific conversion.
I've left the argument in for backwards compatibility; when the API version
is next bumped up, it can be removed.
* separator handling in fromfile is now safe (no fscanf(fp, sep) anymore)
........
r3742 | oliphant | 2007-05-10 16:49:22 -0500 (Thu, 10 May 2007) | 1 line
Remove wasteful check. Fix problem with PyArray_Transpose for large arrays.
........
r3743 | oliphant | 2007-05-10 17:42:48 -0500 (Thu, 10 May 2007) | 1 line
Fix ticket #514 (and probably others) due to inappropriate fixing of largest string type on common type conversion.
........
r3744 | pearu | 2007-05-11 03:20:41 -0500 (Fri, 11 May 2007) | 1 line
Improved error message for missing Python.h.
........
r3745 | pearu | 2007-05-11 07:50:42 -0500 (Fri, 11 May 2007) | 1 line
Clean up setup() calls.
........
r3746 | pearu | 2007-05-11 07:58:31 -0500 (Fri, 11 May 2007) | 1 line
Using meaningful NotFoundError exception for blas_opt and lapack_opt resources.
........
r3747 | pearu | 2007-05-11 08:37:31 -0500 (Fri, 11 May 2007) | 1 line
Raise exception when pyrex is required.
........
Property changes on: branches/multicore
___________________________________________________________________
Name: svnmerge-integrated
- /branches/distutils-revamp:1-2752 /trunk:1-3733
+ /branches/distutils-revamp:1-2752 /trunk:1-3747
Modified: branches/multicore/numpy/core/code_generators/genapi.py
===================================================================
--- branches/multicore/numpy/core/code_generators/genapi.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/core/code_generators/genapi.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -1,3 +1,10 @@
+"""
+Get API information encoded in C files.
+
+See ``find_function`` for how functions should be formatted, and
+``read_order`` for how the order of the functions should be
+specified.
+"""
import sys, os, re
import md5
import textwrap
@@ -2,2 +9,5 @@
+__docformat__ = 'restructuredtext'
+
+# The files under src/ that are scanned for API functions
API_FILES = ['arraymethods.c',
@@ -128,6 +138,27 @@
def find_functions(filename, tag='API'):
+ """
+ Scan the file, looking for tagged functions.
+
+ Assuming ``tag=='API'``, a tagged function looks like::
+
+ /*API*/
+ static returntype*
+ function_name(argtype1 arg1, argtype2 arg2)
+ {
+ }
+
+ where the return type must be on a separate line, the function
+ name must start the line, and the opening ``{`` must start the line.
+
+ An optional documentation comment in ReST format may follow the tag,
+ as in::
+
+ /*API
+ This function does foo...
+ */
+ """
fo = open(filename, 'r')
functions = []
return_type = None
@@ -191,6 +222,11 @@
return functions
def read_order(order_file):
+ """
+ Read the order of the API functions from a file.
+
+ Comments can be put on lines starting with #
+ """
fo = open(order_file, 'r')
order = {}
i = 0
Modified: branches/multicore/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- branches/multicore/numpy/core/include/numpy/ndarrayobject.h 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/core/include/numpy/ndarrayobject.h 2007-05-11 21:49:03 UTC (rev 3748)
@@ -9,17 +9,18 @@
extern "C" CONFUSE_EMACS
#undef CONFUSE_EMACS
#undef CONFUSE_EMACS2
-/* ... otherwise a semi-smart idententer (like emacs) tries to indent
+/* ... otherwise a semi-smart identer (like emacs) tries to indent
everything when you're typing */
#endif
/* This is auto-generated by the installer */
#include "config.h"
-/* There are several places in the code where an array of dimensions is */
-/* allocated statically. This is the size of that static allocation. */
-/* The array creation itself could have arbitrary dimensions but
- * all the places where static allocation is used would need to
- * be changed to dynamic (including inside of several structures)
+/* There are several places in the code where an array of dimensions is
+ * allocated statically. This is the size of that static allocation.
+ *
+ * The array creation itself could have arbitrary dimensions but
+ * all the places where static allocation is used would need to
+ * be changed to dynamic (including inside of several structures)
*/
#define NPY_MAXDIMS 32
@@ -1008,6 +1009,8 @@
#define PyDimMem_RENEW(ptr,size) \
((npy_intp *)PyArray_realloc(ptr,size*sizeof(npy_intp)))
+/* forward declaration */
+struct _PyArray_Descr;
/* These must deal with unaligned and swapped data if necessary */
typedef PyObject * (PyArray_GetItemFunc) (void *, void *);
@@ -1032,8 +1035,12 @@
typedef void (PyArray_VectorUnaryFunc)(void *, void *, npy_intp, void *,
void *);
-typedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);
-typedef int (PyArray_FromStrFunc)(char *, void *, char **, void *);
+/* XXX the ignore argument should be removed next time the API version
+ is bumped. It used to be the separator. */
+typedef int (PyArray_ScanFunc)(FILE *fp, void *dptr,
+ char *ignore, struct _PyArray_Descr *);
+typedef int (PyArray_FromStrFunc)(char *s, void *dptr, char **endptr,
+ struct _PyArray_Descr *);
typedef int (PyArray_FillFunc)(void *, npy_intp, void *);
@@ -1161,7 +1168,7 @@
PyDataType_FLAGCHK(dtype, NPY_ITEM_REFCOUNT)
/* Change dtype hasobject to 32-bit in 1.1 and change its name */
-typedef struct {
+typedef struct _PyArray_Descr {
PyObject_HEAD
PyTypeObject *typeobj; /* the type object representing an
instance of this type -- should not
Modified: branches/multicore/numpy/core/records.py
===================================================================
--- branches/multicore/numpy/core/records.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/core/records.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -136,7 +136,7 @@
# if it's a string return 'SU' return a chararray
# otherwise return a normal array
if obj.dtype.fields:
- return obj.view(recarray)
+ return obj.view(obj.__class__)
if obj.dtype.char in 'SU':
return obj.view(chararray)
return obj
Modified: branches/multicore/numpy/core/setup.py
===================================================================
--- branches/multicore/numpy/core/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/core/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -42,10 +42,16 @@
tc = generate_testcode(target)
from distutils import sysconfig
python_include = sysconfig.get_python_inc()
+ python_h = join(python_include, 'Python.h')
+ if not os.path.isfile(python_h):
+ raise SystemError,\
+ "Non-existing %s. Perhaps you need to install"\
+ " python-dev|python-devel." % (python_h)
result = config_cmd.try_run(tc,include_dirs=[python_include],
library_dirs = default_lib_dirs)
if not result:
- raise "ERROR: Failed to test configuration"
+ raise SystemError,"Failed to test configuration. "\
+ "See previous error messages for more information."
# Python 2.3 causes a segfault when
# trying to re-acquire the thread-state
@@ -351,4 +357,5 @@
if __name__=='__main__':
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
+
Modified: branches/multicore/numpy/core/src/arrayobject.c
===================================================================
--- branches/multicore/numpy/core/src/arrayobject.c 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/core/src/arrayobject.c 2007-05-11 21:49:03 UTC (rev 3748)
@@ -5368,7 +5368,7 @@
return NULL;
}
size *= dims[i];
- if (size <=0 || size > largest) {
+ if (size > largest) {
PyErr_SetString(PyExc_ValueError,
"dimensions too large.");
Py_DECREF(descr);
@@ -6937,15 +6937,13 @@
else {
outtype = PyArray_DescrFromType(outtype_num);
}
- if (PyTypeNum_ISEXTENDED(outtype->type_num) && \
- (PyTypeNum_ISEXTENDED(mintype->type_num) || \
- mintype->type_num==0)) {
+ if (PyTypeNum_ISEXTENDED(outtype->type_num)) {
int testsize = outtype->elsize;
register int chksize, minsize;
chksize = chktype->elsize;
minsize = mintype->elsize;
/* Handle string->unicode case separately
- because string itemsize is twice as large */
+ because string itemsize is 4* as large */
if (outtype->type_num == PyArray_UNICODE &&
mintype->type_num == PyArray_STRING) {
testsize = MAX(chksize, 4*minsize);
Modified: branches/multicore/numpy/core/src/arraytypes.inc.src
===================================================================
--- branches/multicore/numpy/core/src/arraytypes.inc.src 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/core/src/arraytypes.inc.src 2007-05-11 21:49:03 UTC (rev 3748)
@@ -11,7 +11,7 @@
if (mylong == NULL) return (longlong) -1;
vv = mylong;
}
- else Py_INCREF(vv);
+ else Py_INCREF(vv);
ret = PyLong_AsLongLong(vv);
Py_DECREF(vv);
@@ -867,18 +867,9 @@
/****************** scan *************************************/
-#define _ENDSCAN \
- if (num != 1) { \
- if (num == 0) return -3; \
- if (num == EOF) return -4; \
- return -5; \
- } \
- if (sep != NULL) { \
- num = fscanf(fp, sep); \
- if (num == 0) return 0; \
- if (num == EOF) return -1; \
- } \
- return 0
+/* The first ignore argument is for backwards compatibility.
+ Should be removed when the API version is bumped up.
+ */
/**begin repeat
@@ -887,11 +878,9 @@
#format="hd","hu","d","u","ld","lu",LONGLONG_FMT,ULONGLONG_FMT,"f","lf","Lf"#
*/
static int
- at fname@_scan (FILE *fp, @type@ *ip, char *sep, void *ignore)
+ at fname@_scan (FILE *fp, @type@ *ip, void *ignore, PyArray_Descr *ignore2)
{
- int num;
- num = fscanf(fp, "%"@format@, ip);
- _ENDSCAN;
+ return fscanf(fp, "%"@format@, ip);
}
/**end repeat**/
@@ -903,24 +892,24 @@
#format="d","u"#
*/
static int
- at fname@_scan (FILE *fp, @type@ *ip, char *sep, void *ignore)
+ at fname@_scan (FILE *fp, @type@ *ip, void *ignore, PyArray_Descr *ignore2)
{
@btype@ temp;
int num;
num = fscanf(fp, "%"@format@, &temp);
*ip = (@type@) temp;
- _ENDSCAN;
+ return num;
}
/**end repeat**/
static int
-BOOL_scan (FILE *fp, Bool *ip, char *sep, void *ignore)
+BOOL_scan (FILE *fp, Bool *ip, void *ignore, PyArray_Descr *ignore2)
{
int temp;
int num;
num = fscanf(fp, "%d", &temp);
*ip = (Bool) (temp != 0);
- _ENDSCAN;
+ return num;
}
/**begin repeat
@@ -929,8 +918,6 @@
#define @fname at _scan NULL
/**end repeat**/
-#undef _ENDSCAN
-
/****************** fromstr *************************************/
/**begin repeat
@@ -940,7 +927,7 @@
#btype=(long,ulong)*5#
*/
static int
- at fname@_fromstr(char *str, @type@ *ip, char **endptr, void *ignore)
+ at fname@_fromstr(char *str, @type@ *ip, char **endptr, PyArray_Descr *ignore)
{
@btype@ result;
@@ -956,7 +943,7 @@
*/
#if (PY_VERSION_HEX >= 0x02040000) || defined(PyOS_ascii_strtod)
static int
- at fname@_fromstr(char *str, @type@ *ip, char **endptr, void *ignore)
+ at fname@_fromstr(char *str, @type@ *ip, char **endptr, PyArray_Descr *ignore)
{
double result;
Modified: branches/multicore/numpy/core/src/multiarraymodule.c
===================================================================
--- branches/multicore/numpy/core/src/multiarraymodule.c 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/core/src/multiarraymodule.c 2007-05-11 21:49:03 UTC (rev 3748)
@@ -1875,7 +1875,7 @@
ret = (PyArrayObject *)\
PyArray_NewFromDescr(ap->ob_type,
ap->descr,
- n, permutation,
+ n, ap->dimensions,
NULL, ap->data, ap->flags,
(PyObject *)ap);
if (ret == NULL) return NULL;
@@ -1884,6 +1884,7 @@
ret->base = (PyObject *)ap;
Py_INCREF(ap);
+ /* fix the dimensions and strides of the return-array */
for(i=0; i<n; i++) {
ret->dimensions[i] = ap->dimensions[permutation[i]];
ret->strides[i] = ap->strides[permutation[i]];
@@ -2152,7 +2153,8 @@
else if ((stype != NULL) && (intypekind != scalarkind)) { \
/* we need to upconvert to type that
handles both intype and stype
- and don't forcecast the scalars.
+
+ also don't forcecast the scalars.
*/
if (!PyArray_CanCoerceScalar(stype->type_num,
@@ -2186,7 +2188,7 @@
if (mps[i] == NULL) goto fail;
}
Py_DECREF(intype);
- Py_XDECREF(stype);
+ Py_XDECREF(stype);
return mps;
fail:
@@ -5828,34 +5830,237 @@
return Py_None;
}
+
+/* Reading from a file or a string.
+
+ As much as possible, we try to use the same code for both files and strings,
+ so the semantics for fromstring and fromfile are the same, especially with
+ regards to the handling of text representations.
+ */
+
+
+typedef int (*next_element)(void **, void *, PyArray_Descr *, void *);
+typedef int (*skip_separator)(void **, const char *, void *);
+
static int
-_skip_sep(char **ptr, char *sep)
+fromstr_next_element(char **s, void *dptr, PyArray_Descr *dtype,
+ const char *end)
{
- char *a;
- int n;
- n = strlen(sep);
- a = *ptr;
- while(*a != '\0' && (strncmp(a, sep, n) != 0))
- a++;
- if (*a == '\0') return -1;
- *ptr = a+strlen(sep);
- return 0;
+ int r = dtype->f->fromstr(*s, dptr, s, dtype);
+ if (end != NULL && *s > end) {
+ return -1;
+ }
+ return r;
}
-/* steals a reference to dtype -- accepts NULL */
-/*OBJECT_API*/
+static int
+fromfile_next_element(FILE **fp, void *dptr, PyArray_Descr *dtype,
+ void *stream_data)
+{
+ /* the NULL argument is for backwards-compatibility */
+ return dtype->f->scanfunc(*fp, dptr, NULL, dtype);
+}
+
+/* Remove multiple whitespace from the separator, and add a space to the
+ beginning and end. This simplifies the separator-skipping code below.
+*/
+static char *
+swab_separator(char *sep)
+{
+ int skip_space = 0;
+ char *s, *start;
+ s = start = malloc(strlen(sep)+3);
+ /* add space to front if there isn't one */
+ if (*sep != '\0' && !isspace(*sep)) {
+ *s = ' '; s++;
+ }
+ while (*sep != '\0') {
+ if (isspace(*sep)) {
+ if (skip_space) {
+ sep++;
+ } else {
+ *s = ' ';
+ s++; sep++;
+ skip_space = 1;
+ }
+ } else {
+ *s = *sep;
+ s++; sep++;
+ skip_space = 0;
+ }
+ }
+ /* add space to end if there isn't one */
+ if (s != start && s[-1] == ' ') {
+ *s = ' ';
+ s++;
+ }
+ *s = '\0';
+ return start;
+}
+
+/* Assuming that the separator is the next bit in the string (file), skip it.
+
+ Single spaces in the separator are matched to arbitrary-long sequences
+ of whitespace in the input.
+
+ If we can't match the separator, return -2.
+ If we hit the end of the string (file), return -1.
+ Otherwise, return 0.
+ */
+
+static int
+fromstr_skip_separator(char **s, const char *sep, const char *end)
+{
+ char *string = *s;
+ int result = 0;
+ while (1) {
+ char c = *string;
+ if (c == '\0' || (end != NULL && string >= end)) {
+ result = -1;
+ break;
+ } else if (*sep == '\0') {
+ /* matched separator */
+ result = 0;
+ break;
+ } else if (*sep == ' ') {
+ if (!isspace(c)) {
+ sep++;
+ continue;
+ }
+ } else if (*sep != c) {
+ result = -2;
+ break;
+ } else {
+ sep++;
+ }
+ string++;
+ }
+ *s = string;
+ return result;
+}
+
+static int
+fromfile_skip_separator(FILE **fp, const char *sep, void *stream_data)
+{
+ int result = 0;
+ while (1) {
+ int c = fgetc(*fp);
+ if (c == EOF) {
+ result = -1;
+ break;
+ } else if (*sep == '\0') {
+ /* matched separator */
+ ungetc(c, *fp);
+ result = 0;
+ break;
+ } else if (*sep == ' ') {
+ if (!isspace(c)) {
+ sep++;
+ ungetc(c, *fp);
+ }
+ } else if (*sep != c) {
+ ungetc(c, *fp);
+ result = -2;
+ break;
+ } else {
+ sep++;
+ }
+ }
+ return result;
+}
+
+/* Create an array by reading from the given stream, using the passed
+ next_element and skip_separator functions.
+ */
+
+#define FROM_BUFFER_SIZE 4096
+static PyArrayObject *
+array_from_text(PyArray_Descr *dtype, intp num, char *sep, size_t *nread,
+ void *stream, next_element next, skip_separator skip_sep,
+ void *stream_data)
+{
+ PyArrayObject *r;
+ intp i;
+ char *dptr, *clean_sep;
+
+ intp thisbuf = 0;
+ intp size;
+ intp bytes, totalbytes;
+
+ size = (num >= 0) ? num : FROM_BUFFER_SIZE;
+
+ r = (PyArrayObject *)
+ PyArray_NewFromDescr(&PyArray_Type,
+ dtype,
+ 1, &size,
+ NULL, NULL,
+ 0, NULL);
+ if (r == NULL) return NULL;
+ clean_sep = swab_separator(sep);
+ NPY_BEGIN_ALLOW_THREADS;
+ totalbytes = bytes = size * dtype->elsize;
+ dptr = r->data;
+ for (i=0; num < 0 || i < num; i++) {
+ if (next(&stream, dptr, dtype, stream_data) < 0)
+ break;
+ *nread += 1;
+ thisbuf += 1;
+ dptr += dtype->elsize;
+ if (num < 0 && thisbuf == size) {
+ totalbytes += bytes;
+ r->data = PyDataMem_RENEW(r->data, totalbytes);
+ dptr = r->data + (totalbytes - bytes);
+ thisbuf = 0;
+ }
+ if (skip_sep(&stream, clean_sep, stream_data) < 0)
+ break;
+ }
+ if (num < 0) {
+ r->data = PyDataMem_RENEW(r->data, (*nread)*dtype->elsize);
+ PyArray_DIM(r,0) = *nread;
+ }
+ NPY_END_ALLOW_THREADS;
+ free(clean_sep);
+ if (PyErr_Occurred()) {
+ Py_DECREF(r);
+ return NULL;
+ }
+ return r;
+}
+#undef FROM_BUFFER_SIZE
+
+/*OBJECT_API
+
+ Given a pointer to a string ``data``, a string length ``slen``, and
+ a ``PyArray_Descr``, return an array corresponding to the data
+ encoded in that string.
+
+ If the dtype is NULL, the default array type is used (double).
+ If non-null, the reference is stolen.
+
+ If ``slen`` is < 0, then the end of string is used for text data.
+ It is an error for ``slen`` to be < 0 for binary data (since embedded NULLs
+ would be the norm).
+
+ The number of elements to read is given as ``num``; if it is < 0, then
+ then as many as possible are read.
+
+ If ``sep`` is NULL or empty, then binary data is assumed, else
+ text data, with ``sep`` as the separator between elements. Whitespace in
+ the separator matches any length of whitespace in the text, and a match
+ for whitespace around the separator is added.
+ */
static PyObject *
PyArray_FromString(char *data, intp slen, PyArray_Descr *dtype,
- intp n, char *sep)
+ intp num, char *sep)
{
int itemsize;
PyArrayObject *ret;
Bool binary;
-
if (dtype == NULL)
dtype=PyArray_DescrFromType(PyArray_DEFAULT);
-
+
if (PyDataType_FLAGCHK(dtype, NPY_ITEM_IS_POINTER)) {
PyErr_SetString(PyExc_ValueError,
"Cannot create an object array from" \
@@ -5874,7 +6079,7 @@
binary = ((sep == NULL) || (strlen(sep) == 0));
if (binary) {
- if (n < 0 ) {
+ if (num < 0 ) {
if (slen % itemsize != 0) {
PyErr_SetString(PyExc_ValueError,
"string size must be a "\
@@ -5882,9 +6087,9 @@
Py_DECREF(dtype);
return NULL;
}
- n = slen/itemsize;
+ num = slen/itemsize;
} else {
- if (slen < n*itemsize) {
+ if (slen < num*itemsize) {
PyErr_SetString(PyExc_ValueError,
"string is smaller than " \
"requested size");
@@ -5893,111 +6098,40 @@
}
}
- if ((ret = (PyArrayObject *)\
- PyArray_NewFromDescr(&PyArray_Type, dtype,
- 1, &n, NULL, NULL,
- 0, NULL)) == NULL)
- return NULL;
- memcpy(ret->data, data, n*dtype->elsize);
- return (PyObject *)ret;
- }
- else { /* read from character-based string */
- char *ptr;
- PyArray_FromStrFunc *fromstr;
- char *dptr;
- intp nread=0;
- intp index;
-
- fromstr = dtype->f->fromstr;
- if (fromstr == NULL) {
+ ret = (PyArrayObject *)
+ PyArray_NewFromDescr(&PyArray_Type, dtype,
+ 1, &num, NULL, NULL,
+ 0, NULL);
+ if (ret == NULL) return NULL;
+ memcpy(ret->data, data, num*dtype->elsize);
+ } else {
+ /* read from character-based string */
+ size_t nread = 0;
+ char *end;
+ if (dtype->f->scanfunc == NULL) {
PyErr_SetString(PyExc_ValueError,
"don't know how to read " \
- "character strings for given " \
+ "character strings with that " \
"array type");
Py_DECREF(dtype);
return NULL;
}
-
- if (n!=-1) {
- ret = (PyArrayObject *) \
- PyArray_NewFromDescr(&PyArray_Type,
- dtype, 1, &n, NULL,
- NULL, 0, NULL);
- if (ret == NULL) return NULL;
- NPY_BEGIN_ALLOW_THREADS
- ptr = data;
- dptr = ret->data;
- for (index=0; index < n; index++) {
- if (fromstr(ptr, dptr, &ptr, ret) < 0)
- break;
- nread += 1;
- dptr += dtype->elsize;
- if (_skip_sep(&ptr, sep) < 0)
- break;
- }
- if (nread < n) {
- fprintf(stderr, "%ld items requested but "\
- "only %ld read\n",
- (long) n, (long) nread);
- ret->data = \
- PyDataMem_RENEW(ret->data,
- nread * \
- ret->descr->elsize);
- PyArray_DIM(ret,0) = nread;
-
- }
- NPY_END_ALLOW_THREADS
+ if (slen < 0) {
+ end = NULL;
+ } else {
+ end = data + slen;
}
- else {
-#define _FILEBUFNUM 4096
- intp thisbuf=0;
- intp size = _FILEBUFNUM;
- intp bytes;
- intp totalbytes;
- char *end;
- int val;
-
- ret = (PyArrayObject *)\
- PyArray_NewFromDescr(&PyArray_Type,
- dtype,
- 1, &size,
- NULL, NULL,
- 0, NULL);
- if (ret==NULL) return NULL;
- NPY_BEGIN_ALLOW_THREADS
- totalbytes = bytes = size * dtype->elsize;
- dptr = ret->data;
- ptr = data;
- end = data+slen;
- while (ptr < end) {
- val = fromstr(ptr, dptr, &ptr, ret);
- if (val < 0) break;
- nread += 1;
- val = _skip_sep(&ptr, sep);
- if (val < 0) break;
- thisbuf += 1;
- dptr += dtype->elsize;
- if (thisbuf == size) {
- totalbytes += bytes;
- ret->data = PyDataMem_RENEW(ret->data,
- totalbytes);
- dptr = ret->data + \
- (totalbytes - bytes);
- thisbuf = 0;
- }
- }
- ret->data = PyDataMem_RENEW(ret->data,
- nread*ret->descr->elsize);
- PyArray_DIM(ret,0) = nread;
-#undef _FILEBUFNUM
- NPY_END_ALLOW_THREADS
- }
+ ret = array_from_text(dtype, num, sep, &nread,
+ data,
+ (next_element) fromstr_next_element,
+ (skip_separator) fromstr_skip_separator,
+ end);
}
return (PyObject *)ret;
}
static PyObject *
-array_fromString(PyObject *ignored, PyObject *args, PyObject *keywds)
+array_fromstring(PyObject *ignored, PyObject *args, PyObject *keywds)
{
char *data;
Py_ssize_t nin=-1;
@@ -6018,6 +6152,148 @@
}
+
+static PyArrayObject *
+array_fromfile_binary(FILE *fp, PyArray_Descr *dtype, intp num, size_t *nread)
+{
+ PyArrayObject *r;
+ intp start, numbytes;
+
+ if (num < 0) {
+ int fail=0;
+ start = (intp )ftell(fp);
+ if (start < 0) fail=1;
+ if (fseek(fp, 0, SEEK_END) < 0) fail=1;
+ numbytes = (intp) ftell(fp);
+ if (numbytes < 0) fail=1;
+ numbytes -= start;
+ if (fseek(fp, start, SEEK_SET) < 0) fail=1;
+ if (fail) {
+ PyErr_SetString(PyExc_IOError,
+ "could not seek in file");
+ Py_DECREF(dtype);
+ return NULL;
+ }
+ num = numbytes / dtype->elsize;
+ }
+ r = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type,
+ dtype,
+ 1, &num,
+ NULL, NULL,
+ 0, NULL);
+ if (r==NULL) return NULL;
+ NPY_BEGIN_ALLOW_THREADS;
+ *nread = fread(r->data, dtype->elsize, num, fp);
+ NPY_END_ALLOW_THREADS;
+ return r;
+}
+
+/*OBJECT_API
+
+ Given a ``FILE *`` pointer ``fp``, and a ``PyArray_Descr``, return an
+ array corresponding to the data encoded in that file.
+
+ If the dtype is NULL, the default array type is used (double).
+ If non-null, the reference is stolen.
+
+ The number of elements to read is given as ``num``; if it is < 0, then
+ then as many as possible are read.
+
+ If ``sep`` is NULL or empty, then binary data is assumed, else
+ text data, with ``sep`` as the separator between elements. Whitespace in
+ the separator matches any length of whitespace in the text, and a match
+ for whitespace around the separator is added.
+
+ For memory-mapped files, use the buffer interface. No more data than
+ necessary is read by this routine.
+*/
+static PyObject *
+PyArray_FromFile(FILE *fp, PyArray_Descr *dtype, intp num, char *sep)
+{
+ PyArrayObject *ret;
+ size_t nread = 0;
+
+ if (PyDataType_REFCHK(dtype)) {
+ PyErr_SetString(PyExc_ValueError,
+ "cannot read into object array");
+ Py_DECREF(dtype);
+ return NULL;
+ }
+ if (dtype->elsize == 0) {
+ PyErr_SetString(PyExc_ValueError, "0-sized elements.");
+ Py_DECREF(dtype);
+ return NULL;
+ }
+
+ if ((sep == NULL) || (strlen(sep) == 0)) {
+ ret = array_fromfile_binary(fp, dtype, num, &nread);
+ } else {
+ if (dtype->f->scanfunc == NULL) {
+ PyErr_SetString(PyExc_ValueError,
+ "don't know how to read " \
+ "character files with that " \
+ "array type");
+ Py_DECREF(dtype);
+ return NULL;
+ }
+ ret = array_from_text(dtype, num, sep, &nread,
+ fp,
+ (next_element) fromfile_next_element,
+ (skip_separator) fromfile_skip_separator,
+ NULL);
+ }
+ if (((intp) nread) < num) {
+ fprintf(stderr, "%ld items requested but only %ld read\n",
+ (long) num, (long) nread);
+ ret->data = PyDataMem_RENEW(ret->data,
+ nread * ret->descr->elsize);
+ PyArray_DIM(ret,0) = nread;
+ }
+ return (PyObject *)ret;
+}
+
+static PyObject *
+array_fromfile(PyObject *ignored, PyObject *args, PyObject *keywds)
+{
+ PyObject *file=NULL, *ret;
+ FILE *fp;
+ char *sep="";
+ Py_ssize_t nin=-1;
+ static char *kwlist[] = {"file", "dtype", "count", "sep", NULL};
+ PyArray_Descr *type=NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, keywds,
+ "O|O&" NPY_SSIZE_T_PYFMT "s",
+ kwlist,
+ &file,
+ PyArray_DescrConverter, &type,
+ &nin, &sep)) {
+ return NULL;
+ }
+
+ if (type == NULL) type = PyArray_DescrFromType(PyArray_DEFAULT);
+
+ if (PyString_Check(file) || PyUnicode_Check(file)) {
+ file = PyObject_CallFunction((PyObject *)&PyFile_Type,
+ "Os", file, "rb");
+ if (file==NULL) return NULL;
+ }
+ else {
+ Py_INCREF(file);
+ }
+ fp = PyFile_AsFile(file);
+ if (fp == NULL) {
+ PyErr_SetString(PyExc_IOError,
+ "first argument must be an open file");
+ Py_DECREF(file);
+ return NULL;
+ }
+ ret = PyArray_FromFile(fp, type, (intp) nin, sep);
+ Py_DECREF(file);
+ return ret;
+}
+
+
/* steals a reference to dtype (which cannot be NULL) */
/*OBJECT_API */
static PyObject *
@@ -6108,7 +6384,7 @@
}
static PyObject *
-array_fromIter(PyObject *ignored, PyObject *args, PyObject *keywds)
+array_fromiter(PyObject *ignored, PyObject *args, PyObject *keywds)
{
PyObject *iter;
Py_ssize_t nin=-1;
@@ -6128,210 +6404,8 @@
}
-
-
-/* This needs an open file object and reads it in directly.
- memory-mapped files handled differently through buffer interface.
-
-file pointer number in resulting 1d array
-(can easily reshape later, -1 for to end of file)
-type of array
-sep is a separator string for character-based data (or NULL for binary)
- " " means whitespace
-*/
-
/*OBJECT_API*/
static PyObject *
-PyArray_FromFile(FILE *fp, PyArray_Descr *typecode, intp num, char *sep)
-{
- PyArrayObject *r;
- size_t nread = 0;
- PyArray_ScanFunc *scan;
- Bool binary;
-
- if (PyDataType_REFCHK(typecode)) {
- PyErr_SetString(PyExc_ValueError, "cannot read into"
- "object array");
- Py_DECREF(typecode);
- return NULL;
- }
- if (typecode->elsize == 0) {
- PyErr_SetString(PyExc_ValueError, "0-sized elements.");
- Py_DECREF(typecode);
- return NULL;
- }
-
- binary = ((sep == NULL) || (strlen(sep) == 0));
- if (num == -1 && binary) { /* Get size for binary file*/
- intp start, numbytes;
- int fail=0;
- start = (intp )ftell(fp);
- if (start < 0) fail=1;
- if (fseek(fp, 0, SEEK_END) < 0) fail=1;
- numbytes = (intp) ftell(fp);
- if (numbytes < 0) fail=1;
- numbytes -= start;
- if (fseek(fp, start, SEEK_SET) < 0) fail=1;
- if (fail) {
- PyErr_SetString(PyExc_IOError,
- "could not seek in file");
- Py_DECREF(typecode);
- return NULL;
- }
- num = numbytes / typecode->elsize;
- }
-
- if (binary) { /* binary data */
- r = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type,
- typecode,
- 1, &num,
- NULL, NULL,
- 0, NULL);
- if (r==NULL) return NULL;
- NPY_BEGIN_ALLOW_THREADS
- nread = fread(r->data, typecode->elsize, num, fp);
- NPY_END_ALLOW_THREADS
- }
- else { /* character reading */
- intp i;
- char *dptr;
- int done=0;
-
- scan = typecode->f->scanfunc;
- if (scan == NULL) {
- PyErr_SetString(PyExc_ValueError,
- "don't know how to read " \
- "character files with that " \
- "array type");
- Py_DECREF(typecode);
- return NULL;
- }
-
- if (num != -1) { /* number to read is known */
- r = (PyArrayObject *)\
- PyArray_NewFromDescr(&PyArray_Type,
- typecode,
- 1, &num,
- NULL, NULL,
- 0, NULL);
- if (r==NULL) return NULL;
- NPY_BEGIN_ALLOW_THREADS
- dptr = r->data;
- for (i=0; i < num; i++) {
- if (done) break;
- done = scan(fp, dptr, sep, NULL);
- if (done < -2) break;
- nread += 1;
- dptr += r->descr->elsize;
- }
- NPY_END_ALLOW_THREADS
- if (PyErr_Occurred()) {
- Py_DECREF(r);
- return NULL;
- }
- }
- else { /* we have to watch for the end of the file and
- reallocate at the end */
-#define _FILEBUFNUM 4096
- intp thisbuf=0;
- intp size = _FILEBUFNUM;
- intp bytes;
- intp totalbytes;
-
- r = (PyArrayObject *)\
- PyArray_NewFromDescr(&PyArray_Type,
- typecode,
- 1, &size,
- NULL, NULL,
- 0, NULL);
- if (r==NULL) return NULL;
- NPY_BEGIN_ALLOW_THREADS
- totalbytes = bytes = size * typecode->elsize;
- dptr = r->data;
- while (!done) {
- done = scan(fp, dptr, sep, NULL);
-
- /* end of file reached trying to
- scan value. done is 1 or 2
- if end of file reached trying to
- scan separator. Still good value.
- */
- if (done < -2) break;
- thisbuf += 1;
- nread += 1;
- dptr += r->descr->elsize;
- if (!done && thisbuf == size) {
- totalbytes += bytes;
- r->data = PyDataMem_RENEW(r->data,
- totalbytes);
- dptr = r->data + (totalbytes - bytes);
- thisbuf = 0;
- }
- }
- r->data = PyDataMem_RENEW(r->data, nread*r->descr->elsize);
- PyArray_DIM(r,0) = nread;
- num = nread;
- NPY_END_ALLOW_THREADS
-#undef _FILEBUFNUM
- }
- if (PyErr_Occurred()) {
- Py_DECREF(r);
- return NULL;
- }
-
- }
- if (((intp) nread) < num) {
- fprintf(stderr, "%ld items requested but only %ld read\n",
- (long) num, (long) nread);
- r->data = PyDataMem_RENEW(r->data, nread * r->descr->elsize);
- PyArray_DIM(r,0) = nread;
- }
- return (PyObject *)r;
-}
-
-static PyObject *
-array_fromfile(PyObject *ignored, PyObject *args, PyObject *keywds)
-{
- PyObject *file=NULL, *ret;
- FILE *fp;
- char *sep="";
- Py_ssize_t nin=-1;
- static char *kwlist[] = {"file", "dtype", "count", "sep", NULL};
- PyArray_Descr *type=NULL;
-
- if (!PyArg_ParseTupleAndKeywords(args, keywds,
- "O|O&" NPY_SSIZE_T_PYFMT "s",
- kwlist,
- &file,
- PyArray_DescrConverter, &type,
- &nin, &sep)) {
- return NULL;
- }
-
- if (type == NULL) type = PyArray_DescrFromType(PyArray_DEFAULT);
-
- if (PyString_Check(file) || PyUnicode_Check(file)) {
- file = PyObject_CallFunction((PyObject *)&PyFile_Type,
- "Os", file, "rb");
- if (file==NULL) return NULL;
- }
- else {
- Py_INCREF(file);
- }
- fp = PyFile_AsFile(file);
- if (fp == NULL) {
- PyErr_SetString(PyExc_IOError,
- "first argument must be an open file");
- Py_DECREF(file);
- return NULL;
- }
- ret = PyArray_FromFile(fp, type, (intp) nin, sep);
- Py_DECREF(file);
- return ret;
-}
-
-/*OBJECT_API*/
-static PyObject *
PyArray_FromBuffer(PyObject *buf, PyArray_Descr *type,
intp count, intp offset)
{
@@ -7213,9 +7287,9 @@
METH_VARARGS | METH_KEYWORDS, NULL},
{"putmask", (PyCFunction)array_putmask,
METH_VARARGS | METH_KEYWORDS, NULL},
- {"fromstring",(PyCFunction)array_fromString,
+ {"fromstring",(PyCFunction)array_fromstring,
METH_VARARGS|METH_KEYWORDS, NULL},
- {"fromiter",(PyCFunction)array_fromIter,
+ {"fromiter",(PyCFunction)array_fromiter,
METH_VARARGS|METH_KEYWORDS, NULL},
{"concatenate", (PyCFunction)array_concatenate,
METH_VARARGS|METH_KEYWORDS, NULL},
Modified: branches/multicore/numpy/core/tests/test_multiarray.py
===================================================================
--- branches/multicore/numpy/core/tests/test_multiarray.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/core/tests/test_multiarray.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -116,9 +116,28 @@
a = fromstring('\x00\x00\x80?\x00\x00\x00@\x00\x00@@\x00\x00\x80@',dtype='<f4')
assert_array_equal(a, array([1,2,3,4]))
+ def check_string(self):
+ a = fromstring('1,2,3,4', sep=',')
+ assert_array_equal(a, [1., 2., 3., 4.])
+
+ def check_counted_string(self):
+ a = fromstring('1,2,3,4', count=4, sep=',')
+ assert_array_equal(a, [1., 2., 3., 4.])
+ a = fromstring('1,2,3,4', count=3, sep=',')
+ assert_array_equal(a, [1., 2., 3.])
+
+ def check_string_with_ws(self):
+ a = fromstring('1 2 3 4 ', dtype=int, sep=' ')
+ assert_array_equal(a, [1, 2, 3, 4])
+
+ def check_counted_string_with_ws(self):
+ a = fromstring('1 2 3 4 ', count=3, dtype=int, sep=' ')
+ assert_array_equal(a, [1, 2, 3])
+
def check_ascii(self):
- a = fromstring('1 , 2 , 3 , 4',sep=',')
- b = fromstring('1,2,3,4',dtype=float,sep=',')
+ a = fromstring('1 , 2 , 3 , 4', sep=',')
+ b = fromstring('1,2,3,4', dtype=float, sep=',')
+ assert_array_equal(a, [1.,2.,3.,4.])
assert_array_equal(a,b)
class test_zero_rank(NumpyTestCase):
Modified: branches/multicore/numpy/distutils/command/build_src.py
===================================================================
--- branches/multicore/numpy/distutils/command/build_src.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/distutils/command/build_src.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -363,10 +363,14 @@
if pyrex_result.num_errors != 0:
raise RuntimeError("%d errors in Pyrex compile" %
pyrex_result.num_errors)
- else:
+ elif os.path.isfile(target_file):
log.warn("Pyrex needed to compile %s but not available."\
" Using old target %s"\
% (source, target_file))
+ else:
+ raise SystemError,"Non-existing target %r. "\
+ "Perhaps you need to install Pyrex."\
+ % (target_file)
new_sources.append(target_file)
else:
new_sources.append(source)
Modified: branches/multicore/numpy/distutils/core.py
===================================================================
--- branches/multicore/numpy/distutils/core.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/distutils/core.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -130,19 +130,17 @@
distutils.core._setup_stop_after = "commandline"
try:
dist = setup(**new_attr)
+ finally:
distutils.core._setup_distribution = old_dist
distutils.core._setup_stop_after = old_stop
- except Exception,msg:
- distutils.core._setup_distribution = old_dist
- distutils.core._setup_stop_after = old_stop
- raise msg
if dist.help or not _command_line_ok():
# probably displayed help, skip running any commands
return dist
# create setup dictionary and append to new_attr
config = configuration()
- if hasattr(config,'todict'): config = config.todict()
+ if hasattr(config,'todict'):
+ config = config.todict()
_dict_append(new_attr, **config)
# Move extension source libraries to libraries
Modified: branches/multicore/numpy/distutils/misc_util.py
===================================================================
--- branches/multicore/numpy/distutils/misc_util.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/distutils/misc_util.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -530,9 +530,10 @@
caller_frame = get_frame(caller_level)
caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)
self.local_path = get_path(caller_name, top_path)
+ # local_path -- directory of a file (usually setup.py) that
+ # defines a configuration() function.
if top_path is None:
top_path = self.local_path
- self.local_path = '.'
if package_path is None:
package_path = self.local_path
elif os.path.isdir(njoin(self.local_path,package_path)):
Modified: branches/multicore/numpy/distutils/setup.py
===================================================================
--- branches/multicore/numpy/distutils/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/distutils/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -12,4 +12,4 @@
if __name__ == '__main__':
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/distutils/system_info.py
===================================================================
--- branches/multicore/numpy/distutils/system_info.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/distutils/system_info.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -1158,6 +1158,8 @@
class lapack_opt_info(system_info):
+ notfounderror = LapackNotFoundError
+
def calc_info(self):
if sys.platform=='darwin' and not os.environ.get('ATLAS',None):
@@ -1253,6 +1255,8 @@
class blas_opt_info(system_info):
+ notfounderror = BlasNotFoundError
+
def calc_info(self):
if sys.platform=='darwin' and not os.environ.get('ATLAS',None):
Modified: branches/multicore/numpy/distutils/tests/f2py_ext/setup.py
===================================================================
--- branches/multicore/numpy/distutils/tests/f2py_ext/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/distutils/tests/f2py_ext/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -8,4 +8,4 @@
if __name__ == "__main__":
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/distutils/tests/f2py_f90_ext/setup.py
===================================================================
--- branches/multicore/numpy/distutils/tests/f2py_f90_ext/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/distutils/tests/f2py_f90_ext/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -13,4 +13,4 @@
if __name__ == "__main__":
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/distutils/tests/gen_ext/setup.py
===================================================================
--- branches/multicore/numpy/distutils/tests/gen_ext/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/distutils/tests/gen_ext/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -44,4 +44,4 @@
if __name__ == "__main__":
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/distutils/tests/pyrex_ext/setup.py
===================================================================
--- branches/multicore/numpy/distutils/tests/pyrex_ext/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/distutils/tests/pyrex_ext/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -9,4 +9,4 @@
if __name__ == "__main__":
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/distutils/tests/setup.py
===================================================================
--- branches/multicore/numpy/distutils/tests/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/distutils/tests/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -11,4 +11,4 @@
if __name__ == "__main__":
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/distutils/tests/swig_ext/setup.py
===================================================================
--- branches/multicore/numpy/distutils/tests/swig_ext/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/distutils/tests/swig_ext/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -15,4 +15,4 @@
if __name__ == "__main__":
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/f2py/tests/array_from_pyobj/setup.py
===================================================================
--- branches/multicore/numpy/f2py/tests/array_from_pyobj/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/f2py/tests/array_from_pyobj/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -22,4 +22,4 @@
if __name__ == "__main__":
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/fft/setup.py
===================================================================
--- branches/multicore/numpy/fft/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/fft/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -16,4 +16,4 @@
if __name__ == '__main__':
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/lib/setup.py
===================================================================
--- branches/multicore/numpy/lib/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/lib/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -18,4 +18,4 @@
if __name__=='__main__':
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/linalg/setup.py
===================================================================
--- branches/multicore/numpy/linalg/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/linalg/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -28,4 +28,4 @@
if __name__ == '__main__':
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/numarray/setup.py
===================================================================
--- branches/multicore/numpy/numarray/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/numarray/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -15,4 +15,4 @@
if __name__ == '__main__':
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/oldnumeric/mlab.py
===================================================================
--- branches/multicore/numpy/oldnumeric/mlab.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/oldnumeric/mlab.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -55,7 +55,8 @@
return _Nprod(x, axis)
def std(x, axis=0):
- return _Nstd(x, axis)
+ N = asarray(x).shape[axis]
+ return _Nstd(x, axis)*sqrt(N/(N-1.))
def mean(x, axis=0):
return _Nmean(x, axis)
Modified: branches/multicore/numpy/oldnumeric/setup.py
===================================================================
--- branches/multicore/numpy/oldnumeric/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/oldnumeric/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -5,4 +5,4 @@
if __name__ == '__main__':
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/random/setup.py
===================================================================
--- branches/multicore/numpy/random/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/random/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -50,4 +50,4 @@
if __name__ == '__main__':
from numpy.distutils.core import setup
- setup(**configuration(top_path='').todict())
+ setup(configuration=configuration)
Modified: branches/multicore/numpy/testing/numpytest.py
===================================================================
--- branches/multicore/numpy/testing/numpytest.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/testing/numpytest.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -627,7 +627,7 @@
class ScipyTest(NumpyTest):
def __init__(self, package=None):
warnings.warn("ScipyTest is now called NumpyTest; please update your code",
- DeprecationWarning)
+ DeprecationWarning, stacklevel=2)
NumpyTest.__init__(self, package)
Modified: branches/multicore/numpy/testing/setup.py
===================================================================
--- branches/multicore/numpy/testing/setup.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/testing/setup.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -12,5 +12,5 @@
description = "NumPy test module",
url = "http://www.numpy.org",
license = "NumPy License (BSD Style)",
- **configuration(top_path='').todict()
+ configuration = configuration,
)
Modified: branches/multicore/numpy/testing/utils.py
===================================================================
--- branches/multicore/numpy/testing/utils.py 2007-05-11 13:37:31 UTC (rev 3747)
+++ branches/multicore/numpy/testing/utils.py 2007-05-11 21:49:03 UTC (rev 3748)
@@ -180,7 +180,7 @@
header='Items are not equal to %d significant digits:' %
significant,
verbose=verbose)
- assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg
+ assert math.fabs(sc_desired - sc_actual) < pow(10.,-(significant-1)), msg
def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
header=''):
More information about the Numpy-svn
mailing list