Skip to content

BUG: save and load point mass rockets and motors - #1234

Open
MateusStano wants to merge 1 commit into
developfrom
bug/point-mass-save-load
Open

MateusStano wants to merge 1 commit into
developfrom
bug/point-mass-save-load

Conversation

@MateusStano

Copy link
Copy Markdown
Member

Pull request type

  • Code changes (bugfix, features)

Checklist

  • Tests for the changes have been added (if needed)
  • Lint (ruff format, ruff check and pylint on the changed files) has passed locally
  • CHANGELOG.md — no action needed; an LLM workflow auto-updates it after merge

Current behavior

A PointMassMotor, a PointMassRocket and a flight of them can be saved with RocketPyEncoder but not loaded back. There are three separate causes:

  1. PointMassMotor has no from_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'
  2. Rocket.from_dict builds the rocket with arguments PointMassRocket does not accept:
    TypeError: PointMassRocket.__init__() got an unexpected keyword argument 'inertia'
  3. weathercock_coeff is 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

  • PointMassMotor has its own to_dict and from_dict, which keep propellant_initial_mass and propellant_final_mass.
  • PointMassRocket saves weathercock_coeff and is rebuilt with its own constructor arguments.
  • The constructor call of Rocket.from_dict is now a small method, Rocket._new_from_dict, that PointMassRocket overrides. The rest of from_dict (motor, surfaces, rail buttons, parachutes, sensors, controllers) is shared and unchanged.
  • A file saved before this change that lacks weathercock_coeff loads with 0.

Breaking change

  • No

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 without weathercock_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/stochastic and tests/integration/test_encoding.py. The full suite with the slow tests was not run locally.

🤖 Generated with Claude Code

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>
@MateusStano
MateusStano requested a review from a team as a code owner November 21, 2026 01:39
@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.60%. Comparing base (47bbd24) to head (916c7e2).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant