[Numpy-discussion] Different behaviour of python built sum and addition on ndarrays

2012-04-16 Thread Christopher Mutel
So, for both 1.5 and 1.6 (at least), it appears that the builtin sum does not add ndarrays the way "+" (and operator.add) do: a = np.arange(10).reshape((2,5)) b = np.arange(10, 20).reshape((2,5)) sum(a,b) Out[5]: array([[15, 18, 21, 24, 27], [20, 23, 26, 29, 32]]) a + b Out[6]: array([[10,

[Numpy-discussion] take from structured array is faster than boolean indexing, but reshapes columns to 2D

2010-12-21 Thread Christopher Mutel
Dear all- Structured arrays are great, but I am having problems filtering them efficiently. Reading through the mailing list, it seems like boolean arrays are the recommended approach to filtering arrays for arbitrary conditions, but my testing shows that a combination of take and where can be muc