Repository navigation
BUG: save and load point mass rockets and motors - #1234
Open
MateusStano wants to merge 1 commit into
Open
MateusStano wants to merge 1 commit into
MateusStano wants to merge 1 commit into
Conversation
A PointMassMotor, a PointMassRocket and a flight of them could be saved but not loaded: - PointMassMotor had no from_dict, so it was rebuilt from arguments its constructor does not take, and its propellant masses were not saved. - Rocket.from_dict built the rocket with arguments PointMassRocket does not accept (inertia, coordinate_system_orientation). - weathercock_coeff was not saved. The constructor call of Rocket.from_dict is now its own method, which PointMassRocket overrides. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1234 +/- ##
===========================================
+ Coverage 86.55% 86.60% +0.04%
===========================================
Files 131 131
Lines 18255 18272 +17
===========================================
+ Hits 15801 15824 +23
+ Misses 2454 2448 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request type
Checklist
ruff format,ruff checkandpylinton the changed files) has passed locallyCHANGELOG.md— no action needed; an LLM workflow auto-updates it after mergeCurrent behavior
A
PointMassMotor, aPointMassRocketand a flight of them can be saved withRocketPyEncoderbut not loaded back. There are three separate causes:PointMassMotorhas nofrom_dict, so the decoder rebuilds it from arguments its constructor does not take, and its propellant masses are not saved:TypeError: PointMassMotor.__init__() missing 1 required positional argument: 'propellant_initial_mass'Rocket.from_dictbuilds the rocket with argumentsPointMassRocketdoes not accept:TypeError: PointMassRocket.__init__() got an unexpected keyword argument 'inertia'weathercock_coeffis not saved, so it would come back as 0 even with loading fixed.This was raised in the review of #1064 (the rocket part) and is unrelated to that PR, so it is fixed here on its own.
New behavior
PointMassMotorhas its ownto_dictandfrom_dict, which keeppropellant_initial_massandpropellant_final_mass.PointMassRocketsavesweathercock_coeffand is rebuilt with its own constructor arguments.Rocket.from_dictis now a small method,Rocket._new_from_dict, thatPointMassRocketoverrides. The rest offrom_dict(motor, surfaces, rail buttons, parachutes, sensors, controllers) is shared and unchanged.weathercock_coeffloads with 0.Breaking change
Additional information
Tests added (all fail without the source change):
tests/unit/motors/test_point_mass_motor.py: the motor saved and loaded in three forms (constant thrust, a thrust table, with a final propellant mass).tests/unit/rocket/test_point_mass_rocket.py: the rocket with and without a motor, and a file withoutweathercock_coeff.tests/integration/test_encoding.py: a point mass flight, both loaded as saved and re-simulated.Run locally:
tests/unit/rocket,tests/unit/motors,tests/unit/stochasticandtests/integration/test_encoding.py. The full suite with the slow tests was not run locally.🤖 Generated with Claude Code