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: one to any power is still 1. Broken edgecase for int arrays #7651

Merged
merged 1 commit into from
May 19, 2016

Conversation

ewmoore
Copy link
Contributor

@ewmoore ewmoore commented May 19, 2016

Fixes gh-7648.

@mhvk
Copy link
Contributor

mhvk commented May 19, 2016

Ah, looking back now I see this all comes from raising to some power without pow. But I think you are still missing one special case, namely for raising -1 to some power.

@charris charris removed this from the 1.11.1 release milestone May 19, 2016
@charris charris merged commit 2423048 into numpy:master May 19, 2016
@charris
Copy link
Member

charris commented May 19, 2016

Thanks Eric.

@charris
Copy link
Member

charris commented May 19, 2016

@mhvk Oops, indeed.

@charris
Copy link
Member

charris commented May 19, 2016

@ewmoore I'd still like to see this whole thing discussed on the list. We have incompatible behavior between scalars and arrays, plus the change to raise an error for the ufunc for division by zero. Not that there is anything wrong, but because this is a messy corner with some nasty tradeoffs, I'd like to have some sort of consensus as to the proper behavior.

@mhvk
Copy link
Contributor

mhvk commented May 19, 2016

Note that this still leaves -1 ** (negative int) incorrect!

@charris
Copy link
Member

charris commented May 19, 2016

I posted to the list. Note that in 1.10 scalar arrays are not handled as arrays, but return int64. I think we need to propose the behavior we want and test all the integer types, together with +1, -1, 0. The tests do seem somewhat lacking at the moment.

if (in1 == 1) {
*((@type@ *)op1) = 1;
continue;
}
if (in2 < 0 || in1 == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

How about drop the previous if and

if (in2 < 0 && (in1 > 1 || in1 < -1)) {

And a special check for divide by zero.

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

3 participants