[feat] '__eq__' method for SampleList#1053
Open
Shubham-Sahoo wants to merge 6 commits intofacebookresearch:mainfrom
Open
[feat] '__eq__' method for SampleList#1053Shubham-Sahoo wants to merge 6 commits intofacebookresearch:mainfrom
Shubham-Sahoo wants to merge 6 commits intofacebookresearch:mainfrom
Conversation
Check if two SampleLists are equal or not
apsdehal
suggested changes
Aug 26, 2021
Contributor
apsdehal
left a comment
There was a problem hiding this comment.
Thanks for contributing to MMF! Awesome first PR. I have left some comments. Address those and it should be good to land.
mmf/common/sample.py
Outdated
| b = set(fields_other) | ||
|
|
||
| # Comparison between keys and early fail | ||
| if a==b: |
Contributor
There was a problem hiding this comment.
Linter won't be happy with this.
mmf/common/sample.py
Outdated
|
|
||
| # Compare Lists | ||
| else: | ||
| if not self[field]==other.get_field(field): |
Contributor
There was a problem hiding this comment.
Maybe use either key access on both sides or use get_field on both sides.
tests/common/test_sample.py
Outdated
| self.assertFalse(sample_list1 == sample_list3) | ||
| self.assertFalse(sample_list1 == sample_list4) | ||
| self.assertFalse(sample_list2 == sample_list4) | ||
| self.assertFalse(sample_list1 == sample_list5) |
Contributor
There was a problem hiding this comment.
Assert more complex cases and cases which are not equal as well. Try testing SampleList inside SampleList or dict inside SampleList.
Author
|
@apsdehal I have pushed the required changes, please have a look. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added the eq method and tests for SampleList facebookresearch#454