-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Consider changing the behavior of Tensor.__contains__(Tensor) to make more sense #24338
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
Comments
|
A brief glance through https://stackoverflow.com/questions/18320624/how-does-contains-work-for-ndarrays suggests that the reason numpy's behavior is like this might be for backward compatibility. I think this might be one of those cases where we shouldn't follow numpy behavior. If we think about a tensor as a generalized python list, it doesn't make sense for something like |
Related numpy issue about this behavior: numpy/numpy#3016 |
I think we should fix this magic behavior. |
Well, very interesting!
|
I wrote a note on the road, I don’t know if it meets our expectations.
|
Uh oh!
There was an error while loading. Please reload this page.
🐛 Bug
Expected behavior
This particular case should be False. Related: #17733 #24156
The incorrect semantics was introduced in PyTorch 1.2 (May), but no one else has complained about it yet in the three months since.
Environment
pytorch master.
cc @mruberry @rgommers @heitorschueroff
The text was updated successfully, but these errors were encountered: