Skip to content

Commit 6339eb1

Browse files
GMinoruyGui-FernandesBR
authored andcommitted
ENH: adds visual feedback when exporting in csv and json
1 parent b823d6d commit 6339eb1

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

docs/notebooks/monte_carlo_analysis/monte_carlo_class_usage.ipynb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,9 +811,18 @@
811811
},
812812
{
813813
"cell_type": "code",
814-
"execution_count": 41,
814+
"execution_count": null,
815815
"metadata": {},
816-
"outputs": [],
816+
"outputs": [
817+
{
818+
"name": "stdout",
819+
"output_type": "stream",
820+
"text": [
821+
"Results saved to monte_carlo_analysis_outputs/monte_carlo_csv_output_example as .csv file\n",
822+
"Results saved to monte_carlo_analysis_outputs/monte_carlo_json_output_example as .json file\n"
823+
]
824+
}
825+
],
817826
"source": [
818827
"test_dispersion.export_results(\"monte_carlo_analysis_outputs/monte_carlo_csv_output_example\", \"csv\")\n",
819828
"test_dispersion.export_results(\"monte_carlo_analysis_outputs/monte_carlo_json_output_example\", \"json\")"

rocketpy/simulation/monte_carlo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,12 +601,14 @@ def export_results(self, output_filename, output_format):
601601
if output_format == "json":
602602
with open(f"{output_filename}.json", "w", encoding="utf-8") as f:
603603
json.dump(txt_data, f, indent=4)
604+
_SimMonitor.reprint(f"Results saved to {Path(output_filename)} as .json file")
604605
elif output_format == "csv":
605606
output_csv_header = txt_data[0].keys()
606607
with open(f"{output_filename}.csv", "w", newline= "") as f:
607608
output_writer = csv.DictWriter(f, fieldnames=output_csv_header)
608609
output_writer.writeheader()
609610
output_writer.writerows(txt_data)
611+
_SimMonitor.reprint(f"Results saved to {Path(output_filename)} as .csv file")
610612

611613
def __terminate_simulation(self):
612614
"""

0 commit comments

Comments
 (0)