-
-
Notifications
You must be signed in to change notification settings - Fork 194
ENH: Resetable Funcified Methods #385
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
ENH: Resetable Funcified Methods #385
Conversation
Update rocketpy/Function.py Co-authored-by: MateusStano <[email protected]>
Update rocketpy/Function.py Co-authored-by: phmbressan <[email protected]>
For future reference, here are the classes that could start using this resetable function:
|
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.
Great fix, many thanks @giovaniceotto !
I hereby confirm that I've tested in the notebooks and it was running perfectly.
Before the v1.0.0 we should definitely apply this reset feature to other classes too.
Thanks for all the feedbacks. @Gui-FernandesBR, I have added the new method to the I believe all the concerns have already been thoroughly discussed and addressed. Feel free to merge. |
Pull request type
Please check the type of change your PR introduces:
Pull request checklist
Please check if your PR fulfills the following requirements, depending on the type of PR:
Code base additions (for bug fixes / features):
black rocketpy
) has passed locally and any fixes were madepytest --runslow
) have passed locallyWhat is the current behavior?
All methods that use the
funcify_method
decorator from the Function class are cached. Once an underlying quantity that effects the value of these funcified methods is changed, they cannot be easily updated to incorporate the changes made to the class instance.What is the new behavior?
A simple function called
reset_funcified_methods
has been created in the Function module. It can be imported by any multable class which makes use of thefuncify_method
decorator.Both
HybridMotors
andLiquidMotors
have been updated to incorporate the functionreset_funcified_methods
in end of their ´addTank´ method.Does this introduce a breaking change?
Other information
This can be further incorporated in other parts of the code if judged as a good implementation.
This PR does not consider resetting cached properties. In a simple understanding, such methods can be decorated simply by
@property
instead of@cached_property
. If caching is still useful, a similar approach to what was implemented in thereset_funcified_methods
can be done to provide the desired functionality.