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
{{ message }}
Repository navigation
bitshift typing on unsigned operands is tedious to work with #8002
>>> np.uint64(18446744073709551615) >> 2
Traceback (most recent call last):
File "<ipython-input-10-988f6401a88f>", line 1, in <module>
np.uint64(18446744073709551615) >> 2
TypeError: ufunc 'right_shift' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Numpy is probably casting (unsigned, signed) to (float64, float64), which is not defined. Then, it tries to downcast it back to integer, but it is unsafe.
I've hit the same problem. I have thought it would have been better to copy C typing as closely as possible. Then for an algorithm already written in C I can just paste it into python, and not have to worry about wrapping all the constants in uint64.
Here's something I had to write last week that demonstrates the annoyance:
Activity
pitrou commentedon Sep 1, 2016
In Numba we are considering typing based only on the first operand, see numba/numba#2072
sklam commentedon Sep 1, 2016
Numpy is probably casting
(unsigned, signed)to(float64, float64), which is not defined. Then, it tries to downcast it back to integer, but it is unsafe.ahaldane commentedon Sep 22, 2016
I've hit the same problem. I have thought it would have been better to copy C typing as closely as possible. Then for an algorithm already written in C I can just paste it into python, and not have to worry about wrapping all the constants in uint64.
Here's something I had to write last week that demonstrates the annoyance:
seberg commentedon Jan 28, 2024
Effectively fixed by NEP 50 in main/NumPy 2.0. Closing.