-
Notifications
You must be signed in to change notification settings - Fork 188
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
feat: add __repr__ methods for FluxTable, FluxColumn, FluxRecord #281
Conversation
Oh, there is a reference for the convention I described, in the Python docs:
|
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 for your PR 👍
There is a few requirements that should be satisfy before we accept the PR:
Thanks! I was trying to ensure that the reprs fit on a single line (of reasonable length), by showing just a summary of the information, rather than the full contents. This isn't strictly required - e.g. pandas objects use multi-line reprs effectively - but I generally consider it good practice. In particular, if you get a list of FluxTables, which seems quite common, it's easier to see if each one sits on a single line. |
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.
@takluyver, thank you for the explanation, it sounds reasonable. Only two requirements remains:
0d1f333
to
4fa46d4
Compare
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 again for your PR 👍, we are ready to merge into master.
Proposed Changes
__repr__
methods are a convenient feature for exploring objects interactively - i.e. in an interactive shell or a Jupyter notebook. The default representation of an object basically just identifies the type:By defining
__repr__
, objects can display themselves with more useful information:There are loose conventions for how reprs are formatted, though I'm not aware of any reference for them. They generally fit on one line, to simplify formatting in containers. If it's practical to fit in all the information to reconstruct the object, the repr should be a code snippet to construct it (as I've done with FluxColumn). If not, the repr usually looks like
<ClassName detail>
, with whatever details are most likely to convey useful information. I've had a guess at what might be useful for FluxTable & FluxRecord, but I'm happy to revise them.Checklist
pytest tests
completes successfully