You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@maxnoe this is due to how NumPy does promotion for scalars. If you do np.uint8(1) + 1, NumPy effectively does np.uint8(1) + np.asarray(1) which gives you int64. If you do np.array([1], dtype=np.uint8) + 1, NumPy figures out what the "smallest dtype" is that can hold the 1, and figures it is uint8 here. So it will do np.array([1], dtype=np.uint8) + np.uint8(1).
We are trying to push us beyond that behaviour, but it may mean a "NumPy 2.0" (in the sense of: most users will be fine, but careful larger than typical change). My main main start is gh-21103. I also had made a small poll here (Without explaining the issues/reasons in depth, the expectations seem pretty mixed though, unfortunately.)
Ah, of course there could be an argument that bit-shifts should never depend on the dtype of the second argument, which would indeed be a different issue. But I am not sure that is what you mean?
Describe the issue:
Scalar bitshifts seem not to be implemented and are either upcasting to int64 or failing to upcast (for uint64).
Reproduce the code example:
Error message:
NumPy/Python version information:
❯ python -c 'import sys, numpy; print(numpy.version, sys.version)'
1.21.5 3.10.2 (main, Jan 15 2022, 19:56:27) [GCC 11.1.0]
The text was updated successfully, but these errors were encountered: