From 159b127eaee3dc776f9ea831a76be79637c7ed5c Mon Sep 17 00:00:00 2001 From: RoryBarnes Date: Sat, 30 Nov 2024 11:27:15 -0800 Subject: [PATCH] Added error handling if user inputs a standard deviation less than 0 for Gaussian mode. --- vspace/vspace.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/vspace/vspace.py b/vspace/vspace.py index c8e7792..5cc6cb8 100644 --- a/vspace/vspace.py +++ b/vspace/vspace.py @@ -381,11 +381,15 @@ def main(): if mode == 1: # check if user set random mode # if yes, construct array of random samples - array = np.random.normal( - loc=float(values[0]), - scale=float(values[1]), - size=int(randsize), - ) + if (float(values[1]) >= 0): + array = np.random.normal( + loc=float(values[0]), + scale=float(values[1]), + size=int(randsize), + ) + else: + print("ERROR: Standard deviation must be non-negative for option "+name+".") + exit() if "min_cutoff" in vars() and "max_cutoff" not in vars(): # user has set a min value for this parameter # resample any values below until all are > min_cutoff