-
-
Notifications
You must be signed in to change notification settings - Fork 252
ENH: Add Monte Carlo outputs export to CSV/JSON (#242) #912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GMinoruy
wants to merge
10
commits into
RocketPy-Team:develop
Choose a base branch
from
GMinoruy:enh/issue-242-monte-carlo-outputs
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+110
−0
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e51b221
ENH: trying to add Monte Carlo output to csv and json see issue #242
GMinoruy fe7c69e
ENH: corrects errors identified during testing
GMinoruy 1c1c77a
ENH: adds example on how to use the export_results function
GMinoruy ee4bab5
ENH: adds visual feedback when exporting in csv and json
GMinoruy d0cc223
ENH: adds Docstring to the function
GMinoruy 6503273
ENH: adds unit test of the function export_results
GMinoruy 8eecdc9
Update tests/unit/simulation/test_monte_carlo.py
GMinoruy a5e77a8
Simplification of f-string usage
GMinoruy d91ae51
ENH: verifies that files created for tests have proper mock data
GMinoruy 8735ed0
ENH: verifies if the test files actually exists before removing them
GMinoruy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ENH: adds Docstring to the function
- Loading branch information
commit d0cc223ee8fe31f5f1f4e31a2d1cd45ec8702a27
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -590,6 +590,20 @@ def __evaluate_flight_outputs(self, flight, sim_idx): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def export_results(self, output_filename, output_format): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Converts the default Monte Carlo .txt output to .cvs or .json file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| depending on the user's choice | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ---------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output_filename : str | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Name of the file in which the converted data will be saved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output_format : str | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format of the output file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| None | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+593
to
+605
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Converts the default Monte Carlo .txt output to .cvs or .json file | |
| depending on the user's choice | |
| Parameters | |
| ---------- | |
| output_filename : str | |
| Name of the file in which the converted data will be saved | |
| output_format : str | |
| Format of the output file | |
| Returns | |
| ------- | |
| None | |
| """Export Monte Carlo simulation results to CSV or JSON format. | |
| This method reads simulation output data from the `.outputs.txt` file | |
| (specifically, from `self.filename.outputs.txt`) and converts it to either | |
| CSV or JSON format based on user selection. The output file will be | |
| overwritten if it already exists. | |
| Parameters | |
| ---------- | |
| output_filename : str or Path | |
| Path and name of the output file (without extension). The appropriate | |
| extension (.csv or .json) will be added automatically. | |
| output_format : str | |
| Format of the output file. Must be either "csv" or "json" | |
| (case-insensitive). | |
| Returns | |
| ------- | |
| None | |
| Raises | |
| ------ | |
| FileNotFoundError | |
| If the `.outputs.txt` file does not exist. | |
| ValueError | |
| If `output_format` is not "csv" or "json". | |
| Examples | |
| -------- | |
| >>> mc.export_results("results", "csv") | |
| >>> mc.export_results(Path("results_folder/results"), "json") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in docstring: ".cvs" should be ".csv"