-
Notifications
You must be signed in to change notification settings - Fork 897
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
Behaviour of E721 with numpy.dtype #9570
Comments
What about |
Looking at https://github.com/numpy/numpy/blob/5feea41396910a3065c8e79886127fad4cbdebf3/numpy/__init__.pyi#L844, it appears that I suppose we should ask a numpy dev — ping @mhvk — about preferred syntax. |
|
Okay, we can try to special-case it when comparing a |
@mhvk -- Just to clarify, is |
I feel like |
I think it is much safer in general usage to use |
Okay, sounds good. Thanks for chiming in. |
## Summary Per #9570: > `dtype` are a bit of a strange beast, but definitely best thought of as instances, not classes, and they are meant to be comparable not just to their own class, but also to the corresponding scalar types (e.g., `x.dtype == np.float32`) and strings (e.g., `x.dtype == ['i1,i4']`; basically, `__eq__` always tries to do `dtype(other)`. This PR thus allows comparisons to `dtype` in preview. Closes #9570. ## Test Plan `cargo test`
## Summary Per #9570: > `dtype` are a bit of a strange beast, but definitely best thought of as instances, not classes, and they are meant to be comparable not just to their own class, but also to the corresponding scalar types (e.g., `x.dtype == np.float32`) and strings (e.g., `x.dtype == ['i1,i4']`; basically, `__eq__` always tries to do `dtype(other)`. This PR thus allows comparisons to `dtype` in preview. Closes #9570. ## Test Plan `cargo test`
numpy.dtype
is tripping rule E721. I'm not sure it should be..dtype
is an object, e.g. adtype('float64')
.While
x.dtype == float
may not be the best means of testing a dtype, I don't think this is E721.The text was updated successfully, but these errors were encountered: