Skip to content

BUG: sample StochasticFlight inputs once per simulation (#1090) - #1126

Open
thatrandomasiandev wants to merge 2 commits into
RocketPy-Team:developfrom
thatrandomasiandev:bug/1090-dict-generator-single-draw
Open

BUG: sample StochasticFlight inputs once per simulation (#1090)#1126
thatrandomasiandev wants to merge 2 commits into
RocketPy-Team:developfrom
thatrandomasiandev:bug/1090-dict-generator-single-draw

Conversation

@thatrandomasiandev

Copy link
Copy Markdown

Pull request type

  • Code changes (bug fix, features)

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • Lint (black rocketpy/ tests/ / make lint) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md — no action needed; an LLM workflow auto-updates it after merge

Current behavior

MonteCarlo.__run_single_simulation called _randomize_rail_length, _randomize_inclination, and _randomize_heading, each of which invoked next(self.dict_generator()). One simulation therefore drew three times; the Flight mixed values across draws while last_rnd_dict (and .inputs.txt) kept only the last draw. StochasticFlight.create_object had the same pattern for rail_length.

Fixes #1090

New behavior

StochasticFlight._sample_flight_inputs() performs a single draw. create_object and MonteCarlo.__run_single_simulation both use that helper so flown rail/inclination/heading match last_rnd_dict. The _randomize_* helpers remain for single-field callers and still each draw once.

Breaking change

  • No

Additional information

Focused unit tests assert create_object and __run_single_simulation Flight inputs equal last_rnd_dict. Full slow suite not run in this contribution pass.

@thatrandomasiandev
thatrandomasiandev requested a review from a team as a code owner August 11, 2026 01:34
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.53%. Comparing base (e0ff281) to head (f6bc82c).
⚠️ Report is 43 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/stochastic/stochastic_flight.py 50.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1126      +/-   ##
===========================================
+ Coverage    82.18%   82.53%   +0.34%     
===========================================
  Files          122      128       +6     
  Lines        16355    16619     +264     
===========================================
+ Hits         13441    13716     +275     
+ Misses        2914     2903      -11     

☔ 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