Skip to content

r/l shift on uint64 scalar and python int failing #4151

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

Closed
mattip opened this issue Dec 27, 2013 · 3 comments
Closed

r/l shift on uint64 scalar and python int failing #4151

mattip opened this issue Dec 27, 2013 · 3 comments

Comments

@mattip
Copy link
Member

mattip commented Dec 27, 2013

#64 bit ubuntu

np.array(123, dtype='uint64') >> np.array(1, dtype='uint64')
61

np.array(123, dtype='uint64') >> 0
Traceback (most recent call last):
File "", line 1, in
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''

np.version.version
'1.8.0.dev-4a9d23b'

platform.architecture()
('64bit', 'ELF')

@charris
Copy link
Member

charris commented Feb 24, 2014

The problem is that an attempt is made cast the signed 0 and unit64 to a common type. The problem looks specific to array scalar types

In [46]: a = np.array([123]*2, dtype='uint64')

In [47]: a >> 2
Out[47]: array([30, 30], dtype=uint64)

Due to the difference in array/scalar and scalar/scalar casting rules. This isn't the only place this causes a problem.

@ianwlarson
Copy link

This issue also affects me.

@mattip
Copy link
Member Author

mattip commented Sep 18, 2023

On 1.26 this raises a (conceptually correct) 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'"). Closing.

@mattip mattip closed this as completed Sep 18, 2023
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

3 participants