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

Julian Taylor jtaylor.debian at googlemail.com
Fri Oct 10 16:31:04 EDT 2014

On 10.10.2014 11:34, Per.Brodtkorb at ffi.no wrote:
> 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 evaluated conditionally.
> The generalized piecewise function passes all the tests for
> numpy.piecewise function except the undocumented features of
> numpy.piecewise which allows condlist to be a single bool list/array or
> a single int array.

One would think you could already pass two arguments to a function by
using a 2d array but I couldn't get that to work with some short testing.
So this looks like a useful improvement over the current piecewise to me.

Do you want open a pull request on github to discuss the details?

It would be good if it can replace the current piecewise as having two
functions which do very similar things is not so nice.


More information about the NumPy-Discussion mailing list