-
Notifications
You must be signed in to change notification settings - Fork 152
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
added slice + flatten for iterable datapipes #730
Conversation
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.
I chatted with Vitaly and understand what the intention is with the default behavior when nothing is passed in.
We also chatted about changing the name from flatten
to flatten_sample
but that is probably too much and potentially more confusing.
I would recommend:
- Being explicit in the docstring about the
flatten
operation is being applied at the element/sample level. - Adding one example in docstring with the default behavior when nothing is passed in. This can be copied over from one of the unit tests.
Otherwise, LGTM!
@dbish has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
slice_dp = input_dp.slice(0, 2) | ||
self.assertEqual([[0, 1], [3, 4], [6, 7]], list(slice_dp)) | ||
|
||
# Functional Test: filter with list of indices for list |
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.
Same as previous lines?
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.
Overall good.
As part of the exercise you can consider including assertWarns
tests for borderline situations:
https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertWarns
input_dp = IterableWrapper([["zero", ["one", "2"]], ["3", ["4", "5"]], ["6", ["7", "8"]]]) | ||
flatten_dp = input_dp.flatten() | ||
self.assertEqual([["zero", "one", "2"], ["3", "4", "5"], ["6", "7", "8"]], list(flatten_dp)) | ||
|
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.
Nit: Probably include test and mention in the doc, that we are not supporting nesting levels > 1
@dbish has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Please read through our contribution guide prior to
creating your pull request.
Fixes #656
Changes