Skip to content

BUG: avoid scalar statistics for structured Monte Carlo results - #1146

Open
ting-hong-shieh wants to merge 1 commit into
RocketPy-Team:developfrom
ting-hong-shieh:codex/bug-monte-carlo-structured-results
Open

BUG: avoid scalar statistics for structured Monte Carlo results#1146
ting-hong-shieh wants to merge 1 commit into
RocketPy-Team:developfrom
ting-hong-shieh:codex/bug-monte-carlo-structured-results

Conversation

@ting-hong-shieh

Copy link
Copy Markdown

Pull request type

  • Code changes (bugfix)
  • Code maintenance
  • ReadMe, Docs and GitHub updates
  • Other

Closes #1145.

Current behavior

MonteCarlo.set_processed_results() sends all collected output values to NumPy's scalar aggregation functions. Equal-shaped lists and arrays are flattened into a single distribution, while ragged or empty values raise before results can finish loading.

At merge base cb6106a717207dd8fc2dfe1446d80ff75022f21b:

Input observations Result
[[1, 2], [3, 4]] scalar statistics with mean 2.5
two np.array([1, 2]) values scalar statistics with mean 2.5
[[1], [2, 3]] ValueError
[] IndexError

New behavior

Summary statistics are calculated only when every observation is a real-valued scalar. Structured, non-numeric, boolean, mixed, and empty results remain unchanged in results; their existing five-element processed_results tuple is (None, None, None, None, None).

The tuple shape and scalar result behavior remain unchanged.

At head 0c93bf7058222e4997df52981d45a9da4ad25e17, all four inputs above return the five-None tuple without changing their raw values.

Verification

  • .venv/bin/python -m pytest tests/unit/simulation/test_monte_carlo.py -k set_processed_results -q: 9 passed
  • .venv/bin/python -m pytest tests/unit/simulation/test_monte_carlo.py tests/integration/simulation/test_monte_carlo.py -m 'not slow' -q: 50 passed, 5 deselected
  • .venv/bin/ruff check rocketpy/simulation/monte_carlo.py tests/unit/simulation/test_monte_carlo.py: passed
  • .venv/bin/ruff format --check rocketpy/simulation/monte_carlo.py tests/unit/simulation/test_monte_carlo.py: passed
  • git diff --check: passed

The slow Monte Carlo simulation matrix was not run locally.

Environment: RocketPy 1.13.0; Python 3.12.6; NumPy 2.5.2; SciPy 1.18.0; pytest 9.1.1; Ruff 0.16.3; macOS 26.5.2 arm64.

Breaking change

  • No

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.32%. Comparing base (e0ff281) to head (0c93bf7).
⚠️ Report is 53 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1146      +/-   ##
===========================================
+ Coverage    82.18%   83.32%   +1.14%     
===========================================
  Files          122      130       +8     
  Lines        16355    17076     +721     
===========================================
+ Hits         13441    14229     +788     
+ Misses        2914     2847      -67     

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

@ting-hong-shieh
ting-hong-shieh marked this pull request as ready for review August 14, 2026 02:34
@ting-hong-shieh
ting-hong-shieh requested a review from a team as a code owner August 14, 2026 02:34
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.

BUG: avoid scalar statistics for structured Monte Carlo results

1 participant