Skip to content

Commit 112dfcd

Browse files
committed
This cache code is ugly.
1 parent 6a4f275 commit 112dfcd

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

mhkit/utils/cache.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,12 @@ def _load_cache(file_extension, cache_filepath):
120120
elif file_extension == ".pkl":
121121
with open(cache_filepath, "rb") as f:
122122
data_dict = pickle.load(f) # some format of 'data' and 'metadata'
123-
# TODO Must be a better way to handle these if we are writing the cache.
124123
if isinstance(data_dict, tuple):
125-
# CDIP call returns dictionary in size 1 tuple
126-
if len(data_dict) == 1 and isinstance(data_dict[0], dict):
124+
# CDIP call returns dictionary in size 2 tuple with the dictionary in first element
125+
if isinstance(data_dict[0], dict):
127126
data_dict = data_dict[0]
128-
# WPTO hindcast call returns size 2 tuple
129-
if len(data_dict) == 2:
127+
# WPTO hindcast call returns size 2 tuple with data and metadata as separate elements
128+
elif len(data_dict) == 2:
130129
return data_dict[0], data_dict[1]
131130
data, metadata = data_dict["data"], data_dict["metadata"]
132131

0 commit comments

Comments
 (0)