Closed
Description
Comments from (#4792):
The changes applied from this pull request don't seem to work well with multidimensional arrays that have an extra "otherwise" condition:
>>> x = array([[-2.5, -1.5, -0.5],
[ 0.5, 1.5, 2.5]])
>>> np.piecewise(x, [x < 0, x >= 2], [-1, 1, 3])
ValueError: all the input arrays must have same number of dimensions
The same code produces the following result in NumPy 1.8.2:
>>> array([[-1., -1., -1.],
[ 3., 3., 1.]])
If you reshape the array to a single dimension, it works as intended.
Also, I noticed there aren't any multidimensional test cases, so maybe this can be one of them?
These conditions were tested with Python 2.7 / NumPy 1.8.2 and Python 2.7.9 / NumPy 1.9.2.