-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Expand Sequence list #692
Expand Sequence list #692
Conversation
Sequence gets expanded, for better readability. Related issue tensorflow#689 Please enter the commit message for your changes. Lines starting
Thank you for fixing this. This fix seems a little hacky though.
|
I think for every complicated structure we need to new line. I thought of using |
At first I did like you, but I chose to write more general code but I can go back if you think code style should more understandable and readable. |
The problem with Alternatively, would it be possible to modify the
instead of currently:
Then you could update the usage in |
…document_dataset_bug
`tensorflow_datasets.scripts.document_datasets.pprint_features_dict` converted to public function and add types parameter.
@Conchylicultor I find an alternative solution please check it. |
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, this looks much better.
@@ -138,7 +139,7 @@ def __iter__(self): | |||
|
|||
def __repr__(self): | |||
"""Display the feature dictionary.""" | |||
return '{}({})'.format(type(self).__name__, self._feature_dict) | |||
return pprint_features_dict(self._feature_dict, types='FeaturesDict') |
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.
Instead of calling pprint_features_dict
and have the kwargs hack which seems hacky
, I feel it would be nicer to have FeaturesDict simply calling repr()
recursively on its child.
Something like:
def __repr__(self):
lines = ['{}({'.format(type(self).__name__)]
for key, feature in sorted(list(features_dict.items())):
all_sub_lines = '\'{}\': {},'.format(key, feature)
lines.extend(' ' + l for l in all_sub_lines.split('\n')) # Add indentation to all childs
lines.append('})')
return lines.join('\n')
This is more generic as this would works with any feature which is using multiple line. And it avoid having to test insinstance(, FeatureDict)
or hasattr
.
What do you think ?
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'm agree with you but now we don't use the pprint_features_dict
func.
Move `pprint_features_dict` func to `features_dict.py`
Great, thank you. Looks good. I'm merging it now. Also, in |
PiperOrigin-RevId: 257705157
Sequence gets expanded, for better readability.
Related issue #689