Skip to content

BUG: one to any power is still 1. Broken edgecase for int arrays - #7651

Merged
charris merged 1 commit into
numpy:masterfrom
ewmoore:ones_array_pow_fix
May 19, 2016
Merged

charris merged 1 commit into
numpy:masterfrom
ewmoore:ones_array_pow_fix

Conversation

@ewmoore

@ewmoore ewmoore commented May 19, 2016

Copy link
Copy Markdown
Contributor

Fixes gh-7648.

@mhvk

mhvk commented May 19, 2016

Copy link
Copy Markdown
Contributor

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

charris commented May 19, 2016

Copy link
Copy Markdown
Member

Thanks Eric.

@charris

charris commented May 19, 2016

Copy link
Copy Markdown
Member

@mhvk Oops, indeed.

@charris

charris commented May 19, 2016

Copy link
Copy Markdown
Member

@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

mhvk commented May 19, 2016

Copy link
Copy Markdown
Contributor

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

@charris

charris commented May 19, 2016

Copy link
Copy Markdown
Member

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.

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

Copy link
Copy Markdown
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.

3 participants