Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fixed regressions in np.piecewise in ref to #5737 and #5729. #7145

Merged
merged 2 commits into from
Feb 1, 2016

Conversation

bastula
Copy link
Contributor

@bastula bastula commented Jan 30, 2016

Fixed regressions in np.piecewise that were generated as a result of the 0d fixes in #4792.

Unit tests were appropriately added.

The fix for #5737 was created by reusing the old condition creation method which works better for multidimensional arrays.

The fix for #5729 was created by removing the n != n2 as it is not necessary and piecewise still works with the same expected behavior (confirmed via unit tests).

@charris charris added this to the 1.11.0 release milestone Jan 30, 2016
@@ -944,11 +944,15 @@ def piecewise(x, condlist, funclist, *args, **kw):
condlist = condlist.T
if n == n2 - 1: # compute the "otherwise" condition.
totlist = np.logical_or.reduce(condlist, axis=0)
condlist = np.vstack([condlist, ~totlist])
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do this without using try...except? Using exception handling for flow control is kind of ugly. Also, there should be an explanation of why the alternative is correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it should be possible as we can check for the number of dimensions. Thanks for the feedback. I agree the try...except block is ugly and even more so without a specific exception.

charris added a commit that referenced this pull request Feb 1, 2016
BUG: Fixed regressions in np.piecewise in ref to #5737 and #5729.
@charris charris merged commit e36d7ca into numpy:master Feb 1, 2016
@charris
Copy link
Member

charris commented Feb 1, 2016

Thanks @bastula .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants