From c5d7c40c1d850879abd5f2c513afa1a2c5d5987e Mon Sep 17 00:00:00 2001 From: Slasnista Date: Mon, 28 Aug 2017 14:07:55 +0200 Subject: check input parameters with helper functions --- ot/utils.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'ot/utils.py') diff --git a/ot/utils.py b/ot/utils.py index 29ad536..01f2a67 100644 --- a/ot/utils.py +++ b/ot/utils.py @@ -168,6 +168,27 @@ def parmap(f, X, nprocs=multiprocessing.cpu_count()): return [x for i, x in sorted(res)] +def check_params(**kwargs): + """check_params: check whether some parameters are missing + """ + + missing_params = [] + check = True + + for param in kwargs: + if kwargs[param] is None: + missing_params.append(param) + + if len(missing_params) > 0: + print("POT - Warning: following necessary parameters are missing") + for p in missing_params: + print("\n", p) + + check = False + + return check + + class deprecated(object): """Decorator to mark a function or class as deprecated. -- cgit v1.2.3