Skip to content
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

More robust first elem check in encode/cast example #3402

Merged
merged 2 commits into from Dec 8, 2021
Merged

Conversation

mariosasko
Copy link
Collaborator

Fix #3306

Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool thanks !

)
encoded_batch = features.encode_batch(
{
"x": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be properly tested, does the first element has to be an empty list ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because encode_batch calls encode_nested_example which goes from the beginning of the list and tries to find the first element that is "good enough" to perform additional checks, and we consider an element "good enough" if it's not None or if it's not an empty sequence (possible nested). Previously, we would stop on the first element that is not None, but this could lead to issues such as the one this PR fixes.

@lhoestq lhoestq merged commit 18e0adf into master Dec 8, 2021
@lhoestq lhoestq deleted the fix-3306 branch December 8, 2021 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nested sequence feature won't encode example if the first item of the outside sequence is an empty list
2 participants