-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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: Incorrect shape of broadcast result with the exponentiation operator **
.
#4145
Comments
Are we going to fix this for numpy 1.8.x? Otherwise, just finishing up that deprecation will fix the issue. It is a rather corner case deprecation warning, so it may be possible to just finish the deprecation in 1.9 already. |
What do you mean by "just finishing up that deprecation will fix the issue"? |
Well, if you set |
Why does pow have a special case for integers anyway? We don't switch
|
Ah, will open a PR with a fix... Apparently because we optimize (x ** 2) and some other operations like that. |
Operations such as `x**array([2])` would convert the 2 into an integer and loose the dimension information, because the array (at this time, it is deprecated), supports `__index__` even though it is not 0-d. This fixes it, by not trying the index machinery when it was an array, since it is unnecessary. Closes numpygh-4145
Operations such as `x**array([2])` would convert the 2 into an integer and loose the dimension information, because the array (at this time, it is deprecated), supports `__index__` even though it is not 0-d. This fixes it, by not trying the index machinery when it was an array, since it is unnecessary. Closes numpygh-4145
I haven't explored the full range of inputs that produce the error, but when
x
has shape(n,)
andy
has shape(1,1)
, the result ofx ** y
does not have the correct (broadcast) shape. It should be(1, n)
, but in all the numpy versions I've tried (1.6.1, 1.7.1, 1.8.0, and 1.9.0.dev-e7fe68a), the result has shape(n,)
.Also, in numpy 1.8.0 and 1.9.0.dev-e7fe68a, the operation generates an unexpected
DeprecationWarning
.The following shows an example. Python was run with the command
python -W always
.The text was updated successfully, but these errors were encountered: