-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpickle_handler.py
31 lines (23 loc) · 903 Bytes
/
pickle_handler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pprint
import cPickle as pickle
class PickleHandler:
def __init__(self,file_name):
self.file_name = file_name
def write_to_pickle(self, dep_mult_list, stop_cont_mult_list, file_name):
with open(file_name, "wb") as fp:
pickle.dump(dep_mult_list, fp)
pickle.dump(stop_cont_mult_list, fp)
def write_prob_to_pickle(self, prob, file_name):
with open(file_name, "wb") as fp:
pickle.dump(prob, fp)
def read_prob(self, file_name):
with open(file_name, "rb") as fp:
return pickle.load(fp)
def init_all_dicts(self):
with open(self.file_name, "rb") as fp:
dep_mult = pickle.load(fp)
stop_cont_mult = pickle.load(fp)
return dep_mult, stop_cont_mult
if __name__ == "__main__":
pickle_handler = PickleHandler("data/harmonic_values_numpy")
dep,cont_stop = pickle_handler.init_all_dicts()