ENH: Added Crop and Clip Methods to Function Class
Pull request type
- [x] Code changes (enhancement, features)
Checklist
- [x] Lint (black rocketpy/ tests/) has passed locally
- [ ] All tests (pytest tests --runslow) have passed locally
- [x] CHANGELOG.md has been updated (if relevant)
Current behavior
RocketPy Function class has no methods to crop or clip the input and output values of a function to a specific range.
This PR is related to the following issue:
ENH: give me a scissor or apply Function.clip and Function.crop - https://github.com/RocketPy-Team/RocketPy/issues/546
New behavior
It is now possible to specify a limited range of values for input or output variables for an object created from the Function class at any point after initialization of the object by using the crop and clip methods respectively. These methods work for any type of allowed Function source.
Breaking change
No
Additional information
To use the new methods, some examples are provided below to exemplify their syntax in brief:
f.crop([(-1, 1), (-2, 2)]) - For two input variables
f.clip([(-2, 2)]) - For output variable
WE no longer use black, can you please run make format so we can review the PR faster?
All required changes have been updated. Thank you!
All required updates made to code; thank you for the reviews!
I believe this PR is now ready for production. However, as I did some (many) changes yesterday, I believe it would be interesting if another code owner could review the function.py file again. @phmbressan could you take a look at it for us pls?
@codecov-ai-reviewer test
Codecov Report
:x: Patch coverage is 73.91304% with 36 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 80.03%. Comparing base (f17893b) to head (a98631b).
:warning: Report is 18 commits behind head on develop.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| rocketpy/mathutils/function.py | 73.91% | 36 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## develop #817 +/- ##
===========================================
+ Coverage 80.02% 80.03% +0.01%
===========================================
Files 98 103 +5
Lines 12004 12524 +520
===========================================
+ Hits 9606 10024 +418
- Misses 2398 2500 +102
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@Gui-FernandesBR @phmbressan Thank you for the review and merge; I appreciate being able to work on this a lot!