summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-04-13 15:13:57 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-04-13 15:13:57 +0000
commit964039632baab1c44e700693dce1b130db5d6938 (patch)
treeb4d63f0a953e2f5dbdb19b48bc20dd0ad376ebfb
parent6eec6faa0d5fe660305d5f3014a442eefd0f656d (diff)
downloadnumpy-964039632baab1c44e700693dce1b130db5d6938.tar.gz
Fix segfault on indexing (but functionality still not working). Add vectorize test-case (ticket #52). Improve comments on broadcast failure.
-rw-r--r--THANKS.txt5
-rw-r--r--numpy/core/src/arrayobject.c8
-rw-r--r--numpy/lib/tests/test_function_base.py7
3 files changed, 14 insertions, 6 deletions
diff --git a/THANKS.txt b/THANKS.txt
index 30b99f0db..66882e0ad 100644
--- a/THANKS.txt
+++ b/THANKS.txt
@@ -13,7 +13,8 @@ Chris Hanley for help with records.py, testing, and bug fixes.
Travis Vaught and Joe Cooper for administration of numpy.org web site and SVN
Eric Firing for bugfixes.
Arnd Baecker for 64-bit testing
-David Cooke for many code improvements including the auto-generated C-API
+David Cooke for many code improvements including the auto-generated C-API, and optimizations.
Alexander Belopolsky (Sasha) for Masked array bug-fixes and tests and rank-0 array improvements and other code additions
Francesc Altet for unicode and nested record tests and help with nested records
-Tim Hochberg for getting the build working on MSVC
+Tim Hochberg for getting the build working on MSVC, optimization improvements, and code review
+Charles Harris for the sorting code originally written for Numarray.
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index 5d2dd469c..970b3b398 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -1777,8 +1777,10 @@ PyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)
if ((mit->subspace != NULL) && (mit->consec)) {
if (mit->iteraxes[0] > 0) { /* then we need to swap */
_swap_axes(mit, (PyArrayObject **)&arr);
+ if (arr == NULL) return -1;
}
}
+
if ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) {
Py_DECREF(arr);
@@ -7522,9 +7524,9 @@ PyArray_Broadcast(PyArrayMultiIterObject *mit)
mit->dimensions[i] = tmp;
else if (mit->dimensions[i] != tmp) {
PyErr_SetString(PyExc_ValueError,
- "index objects are " \
- "not broadcastable " \
- "to a single shape");
+ "shape mismatch: objects" \
+ " cannot be broadcast" \
+ " to a single shape");
return -1;
}
}
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index fb8ae9763..cf9a35274 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -327,7 +327,12 @@ class test_histogram(ScipyTestCase):
(a,b)=histogram(linspace(0,10,100))
assert(all(a==10))
-
+class test_vectorize( ScipyTestCase ):
+ def check_vectorize( self ):
+ x = linspace(-3,2,10000)
+ f = vectorize(lambda x: x)
+ y = f(x)
+ assert_array_equal(y, x)