RocketPy icon indicating copy to clipboard operation
RocketPy copied to clipboard

ENH: Added Crop and Clip Methods to Function Class

Open Rickisterr opened this issue 7 months ago • 3 comments

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

Rickisterr avatar May 12 '25 17:05 Rickisterr

WE no longer use black, can you please run make format so we can review the PR faster?

Gui-FernandesBR avatar May 12 '25 17:05 Gui-FernandesBR

All required changes have been updated. Thank you!

Rickisterr avatar May 12 '25 17:05 Rickisterr

All required updates made to code; thank you for the reviews!

Rickisterr avatar Jun 17 '25 18:06 Rickisterr

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?

Gui-FernandesBR avatar Jul 26 '25 15:07 Gui-FernandesBR

@codecov-ai-reviewer test

Gui-FernandesBR avatar Jul 26 '25 15:07 Gui-FernandesBR

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.

codecov[bot] avatar Aug 13 '25 00:08 codecov[bot]

@Gui-FernandesBR @phmbressan Thank you for the review and merge; I appreciate being able to work on this a lot!

Rickisterr avatar Aug 22 '25 18:08 Rickisterr