Re: [Numpy-discussion] Apply a function to an array elementwise

2008-12-04 Thread Tim Michelsen
I want to apply a function (myfunc which takes and returns a scalar) to each element in a multi-dimensioned array (data): I can do this: newdata = numpy.array([myfunc(d) for d in data.flat]).reshape(data.shape) But I'm wondering if there's a faster more numpy way. I've looked at the

[Numpy-discussion] Apply a function to an array elementwise

2008-12-03 Thread Elfnor
Hi I want to apply a function (myfunc which takes and returns a scalar) to each element in a multi-dimensioned array (data): I can do this: newdata = numpy.array([myfunc(d) for d in data.flat]).reshape(data.shape) But I'm wondering if there's a faster more numpy way. I've looked at the

Re: [Numpy-discussion] Apply a function to an array elementwise

2008-12-03 Thread Travis Oliphant
Elfnor wrote: Hi I want to apply a function (myfunc which takes and returns a scalar) to each element in a multi-dimensioned array (data): I can do this: newdata = numpy.array([myfunc(d) for d in data.flat]).reshape(data.shape) But I'm wondering if there's a faster more numpy way. I've