mmf
mmf copied to clipboard
[feature] Add __eq__ method to SampleList
🚀 Feature
SampleList frequently require comparisons in tests. It would good to add __eq__
method to SampleList
Pitch
- Compare list of keys and fail early
- Compare each item
- Take special care of tensors
- Add tests
Note: If you are a bootcamper working on this task, assign the internal task to yourself: T71222206
Can I work on this?
@steph-en-m Yes, go ahead.
@apsdehal I would like to work on this issue. I'm not clear of what to compare inside the SampleList __eq__
method. Can you give a clarification on this?
@Shubham-Sahoo Hi, thanks for your interest. In general, iterate over the keys, check if the type is tensor and compare them using torch.equal
otherwise, normally compare them as it is. Let me know if you got the idea.
@apsdehal So it is like comparing all the samples in the sampleList with a given tensor. So the __eq__
method will take an input tensor as well. Please correct me if I'm wrong.
@Shubham-Sahoo To understand the purpose of __eq__
check https://www.pythontutorial.net/python-oop/python-eq/. I hope this makes it clear. In case of SampleList __eq__
method will take in another sample list with which it is being compared to be equal or not.
Hello @apsdehal Is this issue closed?
@apsdehal Can you review my PR and suggest if any changes are required.
@AditiThirdEye @Shubham-Sahoo is working on this.
@Shubham-Sahoo I reviewed your PR, take a look at my comments.
@apsdehal yeah I'm working on the comments.
@apsdehal I have pushed the changes.
Hi @apsdehal is the issue still open? can I take it up?