Skip to content

Commit 487f52d

Browse files
committed
remove some further redundancy in matchup
1 parent d7b7df7 commit 487f52d

1 file changed

Lines changed: 4 additions & 56 deletions

File tree

oceanval/matchall.py

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ def mm_match(ff, model_variable, df, df_times, ds_depths, variable, df_all, laye
203203
if session_info["cache"]:
204204
cache_dir = session_info["cache_dir"]
205205
if cache_dir is not None:
206-
if not os.path.exists(cache_dir):
207-
os.makedirs(cache_dir)
208206
# create a random string
209207
random_string = "".join(
210208
random.choices(
@@ -684,35 +682,12 @@ def matchup(
684682
if not isinstance(strict_names, bool):
685683
raise TypeError("strict_names must be a boolean")
686684
session_info["strict_names"] = strict_names
687-
# convert require to list if it's not None and is a string
688685

686+
gridded = []
689687

690-
# store short title
691-
gridded = None
692-
point = None
693-
694-
# check it is str or list
695-
696-
# make point a list if it's None
697-
if point is None:
698-
point = dict()
699-
point["all"] = []
700-
point["surface"] = []
701-
702-
# if point is str, make it a list
703-
if isinstance(point, str):
704-
point = [point]
705-
706-
if not isinstance(point, list) and not isinstance(point, dict):
707-
raise TypeError("point must be a list or a string")
708-
# if point is a list, convert to a dictionary
709-
if isinstance(point, list):
710-
point_new = copy.deepcopy(point)
711-
point = dict()
712-
point["all"] = point_new
713-
point["surface"] = []
714-
# loop through definition keys
715-
688+
point = dict()
689+
point["all"] = []
690+
point["surface"] = []
716691

717692
if len(definitions.keys) == 0:
718693
raise ValueError("You do not appear to have asked for any variables to be validated!")
@@ -738,33 +713,6 @@ def matchup(
738713
gridded.append(key)
739714
except:
740715
pass
741-
742-
if isinstance(point, dict):
743-
# check keys are valid
744-
for key in point.keys():
745-
if key not in ["all", "surface"]:
746-
raise ValueError("point dictionary keys must be 'all', 'surface'")
747-
# check values are lists
748-
for key in point.keys():
749-
if isinstance(point[key], str):
750-
point[key] = [point[key]]
751-
# if it's None, convert to empty list
752-
if point[key] is None:
753-
point[key] = []
754-
if not isinstance(point[key], list):
755-
raise TypeError("point dictionary values must be lists or strings")
756-
# if any keys are absent, make them empty lists
757-
for key in ["all", "surface"]:
758-
if key not in point.keys():
759-
point[key] = []
760-
761-
# if gridded is str, make it a list
762-
if isinstance(gridded, str):
763-
gridded = [gridded]
764-
# None too
765-
if gridded is None:
766-
gridded = []
767-
768716

769717
# if cache is True, create a cache directory in out_dir
770718
if cache:

0 commit comments

Comments
 (0)