Re: [Numpy-discussion] ufunc for sum of squared difference

2016-11-14 Thread Stephan Hoyer
On Mon, Nov 14, 2016 at 5:40 PM, Matthew Harrigan < harrigan.matt...@gmail.com> wrote: > Essentially it creates a reduce for a function which isn't binary. I > think this would be generally useful. > NumPy already has a generic enough interface for creating such ufuncs. In fact, it's called a

Re: [Numpy-discussion] ufunc for sum of squared difference

2016-11-14 Thread Matthew Harrigan
Still slower and worse uses 2x the memory for the intermediate temporary array. I propose allowing implicit reductions with ufuncs. Specifically if out is provided with shape[axis] = 1, then pass it on to the ufunc with a stride of 0. That should allow this to work: x = np.arange(10) def

Re: [Numpy-discussion] Ensuring one can operate on array-like argument in place

2016-11-14 Thread Chris Barker
I tend to use ndarray.copy() in python code -- no reason you couldn't do the same in Cython. If you want to take any array-like object that may not have a copy() method, you could call asanyarray() first: -CHB On Sat, Nov 12, 2016 at 9:00 AM, Pavlyk, Oleksandr < oleksandr.pav...@intel.com>

Re: [Numpy-discussion] ufunc for sum of squared difference

2016-11-14 Thread eat
Yeah, but it's not so obvious what's happening "under the hoods". Consider this (with an old Win7 machine): Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] np.__version__ '1.11.1' On Mon, Nov 14, 2016 at 10:38 AM, Jerome Kieffer

Re: [Numpy-discussion] ufunc for sum of squared difference

2016-11-14 Thread Jerome Kieffer
On Fri, 11 Nov 2016 11:25:58 -0500 Matthew Harrigan wrote: > I started a ufunc to compute the sum of square differences here > . > It is about 4x faster and uses half the memory compared to >