Add arguments __repr__ in Distribution base class#10373
Add arguments __repr__ in Distribution base class#10373nadavbh12 wants to merge 5 commits intopytorch:masterfrom
Conversation
| return self.__class__.__name__ + '()' | ||
| param_names = [k for k,_ in self.arg_constraints.items()] | ||
| args_string = ', '.join(['{}: {}'.format(p, self.__dict__[p]) for p in param_names]) | ||
| return self.__class__.__name__ + '(' + args_string + ')' |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
facebook-github-bot
left a comment
There was a problem hiding this comment.
ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
torch/distributions/distribution.py
Outdated
| param_names = [k for k,_ in self.arg_constraints.items()] | ||
| args_string = ', '.join(['{}: {}'.format(p, self.__dict__[p]) for p in param_names]) | ||
| args_string = ', '.join(['{}: {}'.format(p, self.__dict__[p] | ||
| if len(self.__dict__[p].shape) == 0 |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/distributions/distribution.py
Outdated
| args_string = ', '.join(['{}: {}'.format(p, self.__dict__[p]) for p in param_names]) | ||
| args_string = ', '.join(['{}: {}'.format(p, self.__dict__[p] | ||
| if len(self.__dict__[p].shape) == 0 | ||
| else self.__dict__[p].shape) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
ezyang
left a comment
There was a problem hiding this comment.
see @vishwakftw's comments
vishwakftw
left a comment
There was a problem hiding this comment.
Could you please fix the lint error? https://travis-ci.org/pytorch/pytorch/builds/415896037?utm_source=github_status&utm_medium=notification
|
@vishwakftw how does this look now? |
|
I think it looks fine now, but Travis is still complaining. Edit: didn’t notice Travis passed. Sorry. |
vishwakftw
left a comment
There was a problem hiding this comment.
Looks good to me, could you add a test in test_distributions to make sure that the __repr__ is called correctly?
facebook-github-bot
left a comment
There was a problem hiding this comment.
ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: Pull Request resolved: pytorch#10373 Differential Revision: D9240316 Pulled By: ezyang fbshipit-source-id: f35c500f61f86e6be405e8bd4040db5146224984
No description provided.