-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
MNT: Add __repr__ method to Parachute class #490
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #490 +/- ##
===========================================
- Coverage 71.05% 70.91% -0.14%
===========================================
Files 55 55
Lines 9261 9265 +4
===========================================
- Hits 6580 6570 -10
- Misses 2681 2695 +14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
@Gui-FernandesBR, I understand the usefullness of these codelines. However, I believe it would be a good practice to follow Python conventions for the __repr__
method, specially since this is mostly for dev use.
From https://docs.python.org/3/reference/datamodel.html#object.repr:
If at all possible, this should look like a valid Python expression that could be used to recreate an object with the same value (given an appropriate environment). If this is not possible, a string of the form <...some useful description...> should be returned.
Options are:
f"<Parachute(name={self.name}, cd_s={self.cd_s}, trigger={self.trigger}, sampling_rate={self.sampling_rate}, lag={self.lag}, noise={self.noise})>"
or, less verbose,
f"<Parachute name={self.name} (cd_s = {self.cd_s:.4f} m2, trigger = {self.trigger})>"
Look at https://stackoverflow.com/questions/44595218/python-repr-for-all-member-variables for more inspiration.
Pull request type
Checklist
black rocketpy/ tests/
) has passed locallypytest --runslow
) have passed locallyCHANGELOG.md
has been updated (if relevant)Current behavior
Enter text here...
New behavior
This is useful for debugging or when you simply call
Rocket.parachutes
and want to see something more readable.Breaking change
Additional information
Opening this now, can describe the PR later, sorry.