-
Notifications
You must be signed in to change notification settings - Fork 939
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
[feat] '__eq__' method for SampleList #1053
base: main
Are you sure you want to change the base?
Conversation
Check if two SampleLists are equal or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linter won't be happy with this.
mmf/common/sample.py
Outdated
|
||
# Compare Lists | ||
else: | ||
if not self[field]==other.get_field(field): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert more complex cases and cases which are not equal as well. Try testing SampleList inside SampleList or dict inside SampleList.
@apsdehal I have pushed the required changes, please have a look. |
Added the eq method and tests for SampleList facebookresearch#454