Skip to content

ENH: let a convergence study be reproduced from one seed - #1198

Open
thc1006 wants to merge 2 commits into
RocketPy-Team:developfrom
thc1006:enh/a-convergence-study-from-one-seed-v2
Open

thc1006 wants to merge 2 commits into
RocketPy-Team:developfrom
thc1006:enh/a-convergence-study-from-one-seed-v2

Conversation

@thc1006

@thc1006 thc1006 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

simulate_convergence had no way to take a seed, so each batch derived a root of its own and the study could not be repeated. Addresses #1077.

Pull request type

  • Code changes (bugfix, features)

Checklist

Current behavior

simulate_convergence runs batches until the confidence interval settles, calling simulate(append=True) for each one. It takes no seed and passes none on, so every batch draws fresh entropy. Two consequences: the same study cannot be run twice, and the same max_simulations reaches a different set of samples depending on the batch_size that divided it up, which is the opposite of what a batch size should mean.

New behavior

It takes a keyword-only random_seed and hands it to each batch. The seed fixes the study rather than the batch: every batch continues the root the rows already record, so a given max_simulations reaches the same samples whichever batch_size was used to get there. Leaving it out keeps today's behavior, which draws fresh entropy and reproduces nothing.

The eight lines that do this are a pass-through. What makes them mean something is #1187, which merged last week: an append now continues the root its rows were drawn with rather than starting a second one, and a simulation takes its seed from its own index rather than from the worker or the batch that happened to run it. Before that, passing the same seed to every batch would have restarted the sequence each time.

Breaking change

  • No

random_seed defaults to None, which is what every existing call already does.

Additional information

Three tests. One runs the same study twice and compares what was drawn; one runs the same max_simulations under two different batch sizes and compares those; the third is the control, that a study with no seed still runs. Accepting the seed and not passing it on turns the first two red and leaves the control green.

This began as a branch from August that carried thirteen commits. Eleven of them have since merged, as #1181 and #1187, so only the two here are new. I took those onto current develop rather than rebasing the branch, since the diff against develop was dominated by what the old base was missing rather than by anything this adds.

Verified on a50d07d5:

pytest tests/                      2647 passed, 10 failed
  the same on develop a50d07d5     2644 passed, 10 failed
ruff check . / ruff format --check clean
pylint rocketpy/ tests/ docs/      10.00/10, exit 0

The ten are the same ten on both, all of them optional dependencies this machine does not have.

Each batch derived a root of its own, so a study could not be repeated and
the same max_simulations reached different samples per batch size.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
@thc1006
thc1006 requested a review from a team as a code owner September 16, 2026 20:54
@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.58%. Comparing base (a50d07d) to head (41344c7).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1198   +/-   ##
========================================
  Coverage    91.58%   91.58%           
========================================
  Files          132      132           
  Lines        18404    18404           
========================================
+ Hits         16855    16856    +1     
+ Misses        1549     1548    -1     

☔ 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