Closed andbiz closed 6 years ago
The main problem is that currently class attributes (?), e.g. start_time, sampling_freq, are not saved.
Save
import pickle
import pyphysio as ph
ibi = ...
pickle.dump(ibi, open( "ibi.p", "wb" ) )
or:
import pyphysio as ph
ibi.save('ibi.p')
Load
import pickle
import pyphysio as ph
ibi = pickle.load( open( "ibi.p", "rb" ) )
or
import pyphysio as ph
ibi = ph.load_pk('ibi.p')
Must use sign.p to retrieve something pickleable and Signal.unp(...) to recover the full object
create a method in Signal, e.g.:
def to_pickle(filename, gzip=True):
#saves a pickle file (with optional gzip compression)
if gzip:
f = gzip.open(filename, mode="wb")
else:
f = open(filename, mode="wb")
pickle.dump(signal.pickleable, f)
f.close()
print('saved in: '+os.getcwd())
And analogous from_pickle(filename)
to load a Signal from a pickle file
Sorry, there is already the method save_pickle... Changed name to to_pickle (develop-andrea)
Should I also rename load_pickle to from_pickle?
Could you post a non working example of pickleing-unpickleing?