refactor: load and dump object moved to misc

This commit is contained in:
Fabian Joswig 2021-11-24 17:26:02 +00:00
parent 42c4baa8ba
commit bb6d380f9f
4 changed files with 36 additions and 34 deletions

View file

@ -1527,38 +1527,6 @@ def pseudo_Obs(value, dvalue, name, samples=1000):
return res
def dump_object(obj, name, **kwargs):
"""Dump object into pickle file.
Parameters
----------
obj : object
object to be saved in the pickle file
name : str
name of the file
path : str
specifies a custom path for the file (default '.')
"""
if 'path' in kwargs:
file_name = kwargs.get('path') + '/' + name + '.p'
else:
file_name = name + '.p'
with open(file_name, 'wb') as fb:
pickle.dump(obj, fb)
def load_object(path):
"""Load object from pickle file.
Parameters
----------
path : str
path to the file
"""
with open(path, 'rb') as file:
return pickle.load(file)
def import_jackknife(jacks, name, idl=None):
"""Imports jackknife samples and returns an Obs