Describe the bug
MonteCarlo.set_processed_results() passes every collected result to NumPy's scalar aggregation functions. This gives structured outputs two inconsistent behaviors:
- equal-shaped lists and NumPy arrays are flattened and reported as one scalar distribution;
- ragged lists and empty result sets raise
ValueError or IndexError.
The raw values are already preserved correctly in MonteCarlo.results. The failure occurs while constructing processed_results.
To reproduce
from rocketpy.simulation import MonteCarlo
monte_carlo = object.__new__(MonteCarlo)
monte_carlo.results = {"samples": [[1, 2], [3, 4]]}
monte_carlo.set_processed_results()
print(monte_carlo.processed_results["samples"])
At cb6106a717207dd8fc2dfe1446d80ff75022f21b, the result is:
(2.5, 2.5, 1.118033988749895, 1.075, 3.925)
A ragged value such as [[1], [2, 3]] instead raises:
ValueError: setting an array element with a sequence
An empty list reaches np.quantile and raises IndexError.
Expected behavior
Summary statistics should only be calculated when every observation is a real-valued scalar. Strings, lists, dictionaries, arrays, mixed values, booleans, and empty results should remain available in results, while the existing five-element processed_results entry should be:
(None, None, None, None, None)
This keeps the public tuple shape unchanged.
Proposed fix
Classify each result series before calling NumPy. Aggregate real scalars and skip scalar statistics for structured or non-numeric observations. Add regression cases for scalar NumPy values, strings, equal and ragged lists, dictionaries, arrays, mixed values, booleans, and empty results.
Environment
- Base SHA:
cb6106a717207dd8fc2dfe1446d80ff75022f21b
- RocketPy 1.13.0
- Python 3.12.6
- NumPy 2.5.2
- SciPy 1.18.0
- pytest 9.1.1
- macOS 26.5.2, arm64
Describe the bug
MonteCarlo.set_processed_results()passes every collected result to NumPy's scalar aggregation functions. This gives structured outputs two inconsistent behaviors:ValueErrororIndexError.The raw values are already preserved correctly in
MonteCarlo.results. The failure occurs while constructingprocessed_results.To reproduce
At
cb6106a717207dd8fc2dfe1446d80ff75022f21b, the result is:A ragged value such as
[[1], [2, 3]]instead raises:An empty list reaches
np.quantileand raisesIndexError.Expected behavior
Summary statistics should only be calculated when every observation is a real-valued scalar. Strings, lists, dictionaries, arrays, mixed values, booleans, and empty results should remain available in
results, while the existing five-elementprocessed_resultsentry should be:This keeps the public tuple shape unchanged.
Proposed fix
Classify each result series before calling NumPy. Aggregate real scalars and skip scalar statistics for structured or non-numeric observations. Add regression cases for scalar NumPy values, strings, equal and ragged lists, dictionaries, arrays, mixed values, booleans, and empty results.
Environment
cb6106a717207dd8fc2dfe1446d80ff75022f21b