Skip to content

ENH: compute rocket static margin lazily (#780) - #1135

Open
thatrandomasiandev wants to merge 2 commits into
RocketPy-Team:developfrom
thatrandomasiandev:enh/780-lazy-static-margin
Open

ENH: compute rocket static margin lazily (#780)#1135
thatrandomasiandev wants to merge 2 commits into
RocketPy-Team:developfrom
thatrandomasiandev:enh/780-lazy-static-margin

Conversation

@thatrandomasiandev

Copy link
Copy Markdown

Summary

  • Compute Rocket.static_margin lazily: a dirty flag is set when geometry/mass/surfaces change; the Function is rebuilt (including set_discrete) only on first access or an explicit evaluate_static_margin() call.
  • add_motor and add_surfaces invalidate instead of eagerly rebuilding; public API (rocket.static_margin as a Function) is unchanged.
  • Fixes ENH: Make Static Margin Calculation Lazy #780

Test plan

  • test_static_margin_lazy_until_accessed — SM not discretized until accessed after adding a surface
  • test_static_margin_rebuilds_after_adding_surface — adding a surface invalidates; access rebuilds once
  • Full tests/unit/rocket/test_rocket.py + tests/integration/test_rocket.py (77 passed)

@thatrandomasiandev
thatrandomasiandev requested a review from a team as a code owner August 11, 2026 01:57
@Gui-FernandesBR Gui-FernandesBR linked an issue Aug 12, 2026 that may be closed by this pull request
Reformat the static margin source lambda. No behaviour change: the
_csys factor stays inside the lambda body, applied to the result.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.33%. Comparing base (e0ff281) to head (7c81711).
⚠️ Report is 72 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1135      +/-   ##
===========================================
+ Coverage    82.18%   84.33%   +2.15%     
===========================================
  Files          122      130       +8     
  Lines        16355    17265     +910     
===========================================
+ Hits         13441    14561    +1120     
+ Misses        2914     2704     -210     

☔ 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.

ENH: Make Static Margin Calculation Lazy

2 participants