RocketPy icon indicating copy to clipboard operation
RocketPy copied to clipboard

ENH: Discretized and No-Pickle Encoding Options

Open phmbressan opened this issue 4 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