Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9640396

Browse files
committed
Fix segfault on indexing (but functionality still not working). Add vectorize test-case (ticket #52). Improve comments on broadcast failure.
1 parent 6eec6fa commit 9640396

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

THANKS.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Chris Hanley for help with records.py, testing, and bug fixes.
1313
Travis Vaught and Joe Cooper for administration of numpy.org web site and SVN
1414
Eric Firing for bugfixes.
1515
Arnd Baecker for 64-bit testing
16-
David Cooke for many code improvements including the auto-generated C-API
16+
David Cooke for many code improvements including the auto-generated C-API, and optimizations.
1717
Alexander Belopolsky (Sasha) for Masked array bug-fixes and tests and rank-0 array improvements and other code additions
1818
Francesc Altet for unicode and nested record tests and help with nested records
19-
Tim Hochberg for getting the build working on MSVC
19+
Tim Hochberg for getting the build working on MSVC, optimization improvements, and code review
20+
Charles Harris for the sorting code originally written for Numarray.

numpy/core/src/arrayobject.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,8 +1777,10 @@ PyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)
17771777
if ((mit->subspace != NULL) && (mit->consec)) {
17781778
if (mit->iteraxes[0] > 0) { /* then we need to swap */
17791779
_swap_axes(mit, (PyArrayObject **)&arr);
1780+
if (arr == NULL) return -1;
17801781
}
17811782
}
1783+
17821784

17831785
if ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) {
17841786
Py_DECREF(arr);
@@ -7522,9 +7524,9 @@ PyArray_Broadcast(PyArrayMultiIterObject *mit)
75227524
mit->dimensions[i] = tmp;
75237525
else if (mit->dimensions[i] != tmp) {
75247526
PyErr_SetString(PyExc_ValueError,
7525-
"index objects are " \
7526-
"not broadcastable " \
7527-
"to a single shape");
7527+
"shape mismatch: objects" \
7528+
" cannot be broadcast" \
7529+
" to a single shape");
75287530
return -1;
75297531
}
75307532
}

numpy/lib/tests/test_function_base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,12 @@ def check_simple(self):
327327
(a,b)=histogram(linspace(0,10,100))
328328
assert(all(a==10))
329329

330-
330+
class test_vectorize( ScipyTestCase ):
331+
def check_vectorize( self ):
332+
x = linspace(-3,2,10000)
333+
f = vectorize(lambda x: x)
334+
y = f(x)
335+
assert_array_equal(y, x)
331336

332337

333338

0 commit comments

Comments
 (0)