RocketPy icon indicating copy to clipboard operation
RocketPy copied to clipboard

ENH: Discretized and No-Pickle Encoding Options

Open phmbressan opened this issue 6 months ago • 1 comments

Pull request type

  • [X] Code changes (bugfix, features)

Checklist

  • [X] Tests for the changes have been added (if needed)
  • [X] Docs have been reviewed and added / updated
  • [X] Lint (black rocketpy/ tests/) has passed locally
  • [X] All tests (pytest tests -m slow --runslow) have passed locally
  • [X] CHANGELOG.md has been updated

Current behavior

The standard RocketPyEncoder currently does not support custom options for users/clients that may have the following needs:

  • Discrete encoding: as documented, this is useful to have the callable defined Functions written out in a human readable format. Of course, this has the drawback that the original callable cannot be exactly reproduced on decoding;
  • No-Pickle encoding: as it is common on I/O libraries/functions (e.g. NumPy save) having a toggle for pickling is beneficial for allowing the user/client having better control of security and output size (pickled objects might get large). This specially useful if there is no interest in decoding the result.

New behavior

The added options discretize and pickle_callables (I am considering change the name to allow_pickle for consistency with other libraries) work as described above. The biggest challenge of the PR (which required a bit of hard coding) was setting discretization bounds for some of RocketPy callable Functions.

Breaking change

  • [ ] Yes
  • [X] No

phmbressan avatar Jun 14 '25 11:06 phmbressan

Codecov Report

Attention: Patch coverage is 90.27027% with 18 lines in your changes missing coverage. Please review.

Project coverage is 80.11%. Comparing base (f17893b) to head (7f8c3c2). Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/environment/environment.py 62.50% 6 Missing :warning:
rocketpy/motors/hybrid_motor.py 50.00% 3 Missing :warning:
rocketpy/motors/tank_geometry.py 62.50% 3 Missing :warning:
...cketpy/rocket/aero_surface/fins/elliptical_fins.py 33.33% 2 Missing :warning:
...ocketpy/rocket/aero_surface/fins/free_form_fins.py 33.33% 2 Missing :warning:
rocketpy/mathutils/function.py 75.00% 1 Missing :warning:
rocketpy/motors/tank.py 90.00% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #827      +/-   ##
===========================================
+ Coverage    80.02%   80.11%   +0.09%     
===========================================
  Files           98       98              
  Lines        12004    12115     +111     
===========================================
+ Hits          9606     9706     +100     
- Misses        2398     2409      +11     

: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 Jun 14 '25 11:06 codecov[bot]