Skip to content

Commit

Permalink
comment out the legacy function mentioned in #105
Browse files Browse the repository at this point in the history
  • Loading branch information
yalinli2 committed Sep 15, 2023
1 parent a6a6be7 commit 126498c
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions qsdsan/utils/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

__all__ = (
'ospath', 'load_data', 'data_path',
'save_pickle', 'load_pickle', 'load_pickled_cmps',
'save_pickle', 'load_pickle',
# 'load_pickled_cmps',
)


Expand Down Expand Up @@ -76,25 +77,28 @@ def load_pickle(path):
f.close()
return obj


def load_pickled_cmps(components_creation_f, pickle_path, pickle=None):
'''
Load components from pickle, update the pickled files if needed.
Parameters
----------
pickle: bool or None.
Whether to pickle the generated components.
If set to None, will pickle when there is no valid pickle file
(either the file is non-existing or it's outdated).
'''
if pickle == True: # repickle if asked to
return components_creation_f(pickle=True)
if ospath.isfile(pickle_path): # try to load pickled file
try: return load_pickle(pickle_path)
except: # want to repickle if there's no pickled file
pickle = True if pickle==None else False
if pickle is not False:
return components_creation_f(pickle=True)
else:
return components_creation_f(pickle=False)
# # Legacy function no longer in use, DO NOT DELETE for now
# def load_pickled_cmps(components_creation_f, pickle_path, pickle=None):
# '''
# Load components from pickle, update the pickled files if needed.
# This function is for util testing and

# Parameters
# ----------
# pickle: bool or None.
# Whether to pickle the generated components.
# If set to None, will pickle when there is no valid pickle file
# (either the file is non-existing or it's outdated).
# components_creation_f : callable.
# Function used to create the components.
# '''
# if pickle == True: # repickle if asked to
# return components_creation_f(pickle=True)
# if ospath.isfile(pickle_path): # try to load pickled file
# try: return load_pickle(pickle_path)
# except: # want to repickle if there's no pickled file
# pickle = True if pickle==None else False
# if pickle is not False:
# return components_creation_f(pickle=True)
# else:
# return components_creation_f(pickle=False)

0 comments on commit 126498c

Please sign in to comment.