Skip to content

Commit 81a8408

Browse files
User-friendlier message when MC fails to generate results
1 parent 650c53c commit 81a8408

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/geophires_monte_carlo/MC_GeoPHIRES3.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ def main(command_line_args=None):
358358
if 'MC_OUTPUT_FILE' in args and args.MC_OUTPUT_FILE is not None
359359
else str(Path(Path(args.Input_file).parent, 'MC_Result.txt').absolute())
360360
)
361+
code_file_name = Path(args.Code_File).name
361362
python_path = 'python'
362363
html_path = ''
363364

@@ -451,6 +452,14 @@ def main(command_line_args=None):
451452
df = pd.DataFrame(results_pd)
452453

453454
# Compute the stats along the specified axes.
455+
if len(results) < 1:
456+
# TODO surface actual exceptions instead of giving this generic message
457+
raise RuntimeError(
458+
'No MC results generated, '
459+
f'this is likely caused by {code_file_name} throwing an exception '
460+
f'when run with your input file.'
461+
)
462+
454463
mins = np.nanmin(results, 0)
455464
maxs = np.nanmax(results, 0)
456465
medians = np.nanmedian(results, 0)

0 commit comments

Comments
 (0)