8000 Piecewise regression with multidimensional arrays with extra 'otherwise' condition · Issue #5737 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
Piecewise regression with multidimensional arrays with extra 'otherwise' condition #5737
Closed
@bastula

Description

@bastula

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0