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: shift with a negative number should fail #13898

Open
mattip opened this issue Jul 3, 2019 · 1 comment
Open

BUG: shift with a negative number should fail #13898

mattip opened this issue Jul 3, 2019 · 1 comment

Comments

@mattip
Copy link
Member

mattip commented Jul 3, 2019

xref gh-13739

A negative shift is undefined in C. Python raises a ValueError, numpy returns the undefined values. We should at least warn, and probably raise an Error.

>>> a = np.arange(4)
>>> 10 << -1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: negative shift count
>>> a << -1
array([-9223372036854775808,                    0, -9223372036854775808,
                          0])
@mattip
Copy link
Member Author

mattip commented Sep 18, 2023

The last example now returns array([0, 0, 0, 0]), but should it raise?

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

No branches or pull requests

1 participant