[Numpy-discussion] Any interest in a generalized piecewise function?

2014-10-10 Thread Per.Brodtkorb
I have worked on a generalized piecewise function (genpiecewise) that are simpler and more general than the current numpy.piecewise implementation. The new generalized piecewise function allows functions of the type f(x0, x1,.. , xn) i.e. to have arbitrary number of input arguments that are eval

Re: [Numpy-discussion] Any interest in a generalized piecewise function?

2014-10-13 Thread Per.Brodtkorb
Ok, I will open a pull request. But before I do so, I would like to know what kind of pull request to make. Ideally I think the call signature for piecewise should be like this: def piecewise(condlist, funclist, xi=None, fillvalue=numpy.nan, args=(), **kw): or this: def piecewise(condlist, fun

Re: [Numpy-discussion] Why do mgrid and meshgrid not return broadcast arrays?

2017-03-08 Thread Per.Brodtkorb
Hi, Juan. Meshgrid can actually give what you want, but you must use the options: copy=False and indexing=’ij’. In [7]: %timeit np.meshgrid(np.arange(512), np.arange(512)) 1000 loops, best of 3: 1.24 ms per loop In [8]: %timeit np.meshgrid(np.arange(512), np.arange(512), copy=False) 1 loop

Re: [Numpy-discussion] Why do mgrid and meshgrid not return broadcast arrays?

2017-03-09 Thread Per.Brodtkorb
The reason for returning copies from meshgrid as default instead of views into to input arrays, was to not break backwards compatibility. The old meshgrid returned copied arrays, which is safe if you need to write to those arrays. If you use copy=False, a view into the original arrays are returne