From 25eab083ac3f7ac890202e74c0a0ec6e90ea520b Mon Sep 17 00:00:00 2001 From: Mendez Date: Tue, 9 Apr 2024 08:12:37 -0500 Subject: [PATCH] raise valueError when all areas.json file are empty --- src/aclimate_cpt/01_prediccion.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/aclimate_cpt/01_prediccion.py b/src/aclimate_cpt/01_prediccion.py index 8f39473..1e2f54e 100644 --- a/src/aclimate_cpt/01_prediccion.py +++ b/src/aclimate_cpt/01_prediccion.py @@ -1212,7 +1212,10 @@ def cpt_merge_x_files(file_paths): items_lgth = {k: sum([len(x["areas"]) for x in val]) for k,val in init_params.items()} empty_dpt = [k for k,v in items_lgth.items() if v == 0] lgth_list = [v for k,v in items_lgth.items()] +bool_lgth = [x == 0 for x in lgth_list] + if len(empty_dpt) >0: + Warning("Empty areas.json file found") for idx in range(len(items_lgth)): if lgth_list[idx] == 0: dir_names.pop(idx) @@ -1220,9 +1223,9 @@ def cpt_merge_x_files(file_paths): path_stations.pop(idx) for nm in empty_dpt: init_params.pop(nm) - - +if all(bool_lgth): + raise ValueError("departments has ares.json file empty") month = int(date.today().strftime("%m")) year = int(date.today().strftime("%Y"))