Skip to content

ENH: Monte Carlo Formatting Options (#945)#947

Open
khushalkottaru wants to merge 8 commits intoRocketPy-Team:masterfrom
khushalkottaru:enh/issue-945-monte-carlo-formats
Open

ENH: Monte Carlo Formatting Options (#945)#947
khushalkottaru wants to merge 8 commits intoRocketPy-Team:masterfrom
khushalkottaru:enh/issue-945-monte-carlo-formats

Conversation

@khushalkottaru
Copy link
Copy Markdown

Pull request type

  • Code changes (bugfix, features)

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md has been updated (if relevant)

Current behavior

The MonteCarlo class only reads and writes .txt files (JSONL format, one JSON object per line) for simulation inputs, outputs, and errors. Users who want to analyze results in Excel or other tools must manually convert these files to CSV or JSON themselves.

New behavior

The MonteCarlo class can now directly export simulation results to CSV and JSON formats, and import previously exported CSV/JSON files back in. New methods:

  • export_outputs_to_csv(filename) / export_outputs_to_json(filename)
  • export_inputs_to_csv(filename, flatten=False) / export_inputs_to_json(filename)
  • export_errors_to_csv(filename, flatten=False) / export_errors_to_json(filename)

The existing .txt (JSONL) format remains the default for simulation output since it supports streaming writes. CSV/JSON are post-processing export targets. The import_outputs, import_inputs, and import_errors methods also now accept .csv and .json files in addition to .txt.

Breaking change

  • Yes
  • No

Additional information

Related to issue #945.

@khushalkottaru khushalkottaru requested a review from a team as a code owner March 31, 2026 01:57
@khushalkottaru
Copy link
Copy Markdown
Author

Will update changelog.md and docs as needed soon.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.17%. Comparing base (1e748d8) to head (0d3c9a0).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
rocketpy/simulation/monte_carlo.py 90.90% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #947      +/-   ##
==========================================
+ Coverage   81.12%   81.17%   +0.05%     
==========================================
  Files         107      107              
  Lines       13881    13967      +86     
==========================================
+ Hits        11261    11338      +77     
- Misses       2620     2629       +9     

☔ View full report in Codecov by Sentry.
📢 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