Skip to content

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

Merged
merged 7 commits into from
Jun 30, 2023

Conversation

giovaniceotto
Copy link
Member

@giovaniceotto giovaniceotto commented Jun 27, 2023

Pull request type

Please check the type of change your PR introduces:

  • Code base additions (bugfix, features)

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):

    • Tests for the changes have been added
    • Docs have been reviewed and added / updated if needed
    • Lint (black rocketpy) has passed locally and any fixes were made
    • All tests (pytest --runslow) have passed locally

What 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 the funcify_method decorator.

Both HybridMotors and LiquidMotors have been updated to incorporate the function reset_funcified_methods in end of their ´addTank´ method.

Does this introduce a breaking change?

  • Yes
  • No

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 the reset_funcified_methods can be done to provide the desired functionality.

@giovaniceotto giovaniceotto requested a review from phmbressan June 27, 2023 03:15
@Gui-FernandesBR Gui-FernandesBR added this to the Release v1.0.0 milestone Jun 27, 2023
Gui-FernandesBR and others added 3 commits June 29, 2023 03:26
Update rocketpy/Function.py

Co-authored-by: MateusStano <[email protected]>
Update rocketpy/Function.py

Co-authored-by: phmbressan <[email protected]>
@Gui-FernandesBR
Copy link
Member

For future reference, here are the classes that could start using this resetable function:

  • SolidMotor (evaluateGeometry method)
  • Rocket (evaluate..... several methods)

Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a 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.

@giovaniceotto
Copy link
Member Author

Thanks for all the feedbacks.

@Gui-FernandesBR, I have added the new method to the evaluateGeometry method in the SolidMotor class. However, I have not added it to the Rocket class since it does not have any funcified methods.

I believe all the concerns have already been thoroughly discussed and addressed. Feel free to merge.

@Gui-FernandesBR Gui-FernandesBR merged commit 031db97 into enh/liquid-motors Jun 30, 2023
@Gui-FernandesBR Gui-FernandesBR deleted the enh/resetable-funcified-methods branch June 30, 2023 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants