From 0f2f320c30155d1df8bdfb9b5c762f13a9e4a911 Mon Sep 17 00:00:00 2001 From: Giovanni La Mura <giovanni.lamura@inaf.it> Date: Mon, 14 Apr 2025 16:01:15 +0200 Subject: [PATCH] Ensure that random generation parameters are optional --- src/scripts/model_maker.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/scripts/model_maker.py b/src/scripts/model_maker.py index db84889..066da49 100755 --- a/src/scripts/model_maker.py +++ b/src/scripts/model_maker.py @@ -371,9 +371,11 @@ def load_model(model_file): if (len_vec_x == 0): # Generate random cluster rnd_seed = int(model['system_settings']['rnd_seed']) - max_rad = float(model['particle_settings']['max_rad']) - # random_aggregate() checks internally whether application is INCLUSION - #random_aggregate(sconf, gconf, rnd_seed, max_rad) + try: + max_rad = float(model['particle_settings']['max_rad']) + except KeyError: + print("ERROR: random model generation requires specification of particle_settings:max_rad.") + return (None, None) rnd_engine = "COMPACT" try: rnd_engine = model['system_settings']['rnd_engine'] @@ -386,6 +388,7 @@ def load_model(model_file): print("ERROR: compact random generator works only when all sphere types have the same radius.") return (None, None) elif (rnd_engine == "LOOSE"): + # random_aggregate() checks internally whether application is INCLUSION check = random_aggregate(sconf, gconf, rnd_seed, max_rad) else: print("ERROR: unrecognized random generator engine.") -- GitLab