Skip to content
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

ENH: Simulation Save and Load in JSON Files #695

Merged
merged 11 commits into from
Nov 12, 2024

Conversation

phmbressan
Copy link
Collaborator

@phmbressan phmbressan commented Sep 22, 2024

Pull request type

  • Code changes (bugfix, features)

Checklist

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

New behavior

This PR improves rocketpy encoding and introduces decoding functionalities. The way this works is:

  • If the is a to_dict or from_dict method, they are used to perform the (de)encoding;
  • Otherwise, a default encoding of all vars() and constructor based decoding is done.

Breaking change

  • Yes
  • No

Additional information

PR #679 should be merged first.

Here are some of the steps that could be improved:

  • Verify why the test for hybrid motor flight requires higher tolerances;
    • Corrected, no higher tolerances needed anymore.
  • Test if all of the atmospheric models of Environments can be decoded without requiring re-read of files or API;
  • Evaluate whether we should encode outputs or only the minimum required information to decode the class from its init;
    • Option for including outputs or not was added.
  • (Optional) Expand implementation to AirBrakes + Controllers and new classes.

Some important remarks:

  • The simple getting started simulation is essentially identical comparing the store & load, the only difference is the random lag and noise from Parachute class. I could not found a simple solution to reset those and always get the same results.

@phmbressan phmbressan added the Enhancement New feature or request, including adjustments in current codes label Sep 22, 2024
@phmbressan phmbressan added this to the Release v1.X.0 milestone Sep 22, 2024
@phmbressan phmbressan self-assigned this Sep 22, 2024
@phmbressan phmbressan requested a review from a team as a code owner September 22, 2024 15:28
Copy link

codecov bot commented Sep 22, 2024

Codecov Report

Attention: Patch coverage is 81.19891% with 69 lines in your changes missing coverage. Please review.

Project coverage is 76.38%. Comparing base (7c18881) to head (5d1c585).
Report is 3 commits behind head on enh/sim-encoding.

Files with missing lines Patch % Lines
rocketpy/environment/environment.py 63.82% 17 Missing ⚠️
rocketpy/_encoders.py 81.25% 9 Missing ⚠️
rocketpy/motors/tank.py 80.48% 8 Missing ⚠️
...ocketpy/rocket/aero_surface/fins/free_form_fins.py 33.33% 6 Missing ⚠️
rocketpy/motors/tank_geometry.py 83.87% 5 Missing ⚠️
...cketpy/rocket/aero_surface/fins/elliptical_fins.py 37.50% 5 Missing ⚠️
rocketpy/simulation/flight.py 37.50% 5 Missing ⚠️
rocketpy/motors/motor.py 76.47% 4 Missing ⚠️
rocketpy/rocket/components.py 42.85% 4 Missing ⚠️
rocketpy/mathutils/vector_matrix.py 66.66% 3 Missing ⚠️
... and 2 more
Additional details and impacted files
@@                 Coverage Diff                  @@
##           enh/sim-encoding     #695      +/-   ##
====================================================
+ Coverage             76.37%   76.38%   +0.01%     
====================================================
  Files                    94       94              
  Lines                 11343    11341       -2     
====================================================
  Hits                   8663     8663              
+ Misses                 2680     2678       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@GabrielBarberini GabrielBarberini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@phmbressan phmbressan changed the base branch from develop to enh/sim-encoding November 8, 2024 23:09
@Gui-FernandesBR
Copy link
Member

@phmbressan , as previously discussed, can you leave only one of the #679 and #695 open please?

@phmbressan phmbressan merged commit 328a25d into enh/sim-encoding Nov 12, 2024
10 checks passed
@phmbressan phmbressan deleted the enh/sim-decoding branch November 12, 2024 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request, including adjustments in current codes
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

3 participants