Skip to content

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

Merged
MateusStano merged 1 commit into
developfrom
bug/point-mass-save-load
Nov 22, 2026
Merged

MateusStano merged 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.

@Gui-FernandesBR Gui-FernandesBR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, really small changes

@MateusStano
MateusStano merged commit c09b3e0 into develop Nov 22, 2026
10 checks passed
@MateusStano
MateusStano deleted the bug/point-mass-save-load branch November 22, 2026 00:24
MateusStano added a commit that referenced this pull request Nov 28, 2026
Describe the forecast reuse and the opt-in disk cache that replaced the
first cache (#1219), and add the PRs merged after the backfill: #1221,
#1222, #1223, #1224, #1231, #1232, #1234, #1239 and #1242.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
MateusStano added a commit that referenced this pull request Nov 28, 2026
* DOC: backfill the v1.14.0 changelog

The changelog automation has not run since #1112, so the PRs merged into develop after it were missing from [Unreleased]. Add them, add the entries for #1225, #1226 and #1227, update the tip-off, tube-fins and parachute-seed entries to what the release ships, and drop the raw commit link, the back-merge entry and the duplicate StochasticFreeFormFins entry.

Related to #1209

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XDW575d9C9zpS7Z1v2KXVq

* DOC: add a Breaking changes section to the v1.14.0 changelog

List what changes for a v1.13.0 user: Monte Carlo seeding and numbering, the deprecated static_margin assignment, the parachute trigger ValueError on the rail, the shifted flight results, and the sensor default temperature.

Related to #1209

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XDW575d9C9zpS7Z1v2KXVq

* DOC: bring the v1.14.0 changelog up to date with develop

Describe the forecast reuse and the opt-in disk cache that replaced the
first cache (#1219), and add the PRs merged after the backfill: #1221,
#1222, #1223, #1224, #1231, #1232, #1234, #1239 and #1242.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: MateusStano <mateusstano@usp.br>
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.

2 participants