BUG: sample StochasticFlight inputs once per simulation (#1090) - #1126
BUG: sample StochasticFlight inputs once per simulation (#1090)#1126thatrandomasiandev wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
|
I compared the flight inputs at current // develop
{
"flown": {"heading": 53.55816157603624, "inclination": 81.41474397857291, "rail_length": 5.2},
"logged": {"heading": 53.55816157603624, "inclination": 83.62213583873555, "rail_length": 5.2}
}
// PR head
{
"flown": {"heading": 52.78714695725011, "inclination": 85.16622077057734, "rail_length": 5.2},
"logged": {"heading": 52.78714695725011, "inclination": 85.16622077057734, "rail_length": 5.2}
}The absolute sampled values differ between implementations because the head intentionally makes one draw instead of three. The relevant invariant is that the values flown and recorded are identical within the same run; that fails on
Environment: Python 3.12.6; NumPy 2.5.2; pytest 9.1.1; macOS 26.5.2 arm64. |
Pull request type
Checklist
black rocketpy/ tests//make lint) has passed locallypytest tests -m slow --runslow) have passed locallyCHANGELOG.md— no action needed; an LLM workflow auto-updates it after mergeCurrent behavior
MonteCarlo.__run_single_simulationcalled_randomize_rail_length,_randomize_inclination, and_randomize_heading, each of which invokednext(self.dict_generator()). One simulation therefore drew three times; the Flight mixed values across draws whilelast_rnd_dict(and.inputs.txt) kept only the last draw.StochasticFlight.create_objecthad the same pattern forrail_length.Fixes #1090
New behavior
StochasticFlight._sample_flight_inputs()performs a single draw.create_objectandMonteCarlo.__run_single_simulationboth use that helper so flown rail/inclination/heading matchlast_rnd_dict. The_randomize_*helpers remain for single-field callers and still each draw once.Breaking change
Additional information
Focused unit tests assert create_object and
__run_single_simulationFlight inputs equallast_rnd_dict. Full slow suite not run in this contribution pass.