-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Labels
Description
The problem: .names doubles after interacting with pickle, cPickle and dill.
How to reproduce (test.txt):
import gromacs.formats as gmx
import os
import pickle
def load_xvg(filepath, failsafe=2):
xvg_file = gmx.XVG()
xvg_file.read(filepath)
return xvg_file
def test_fnc(xvg_file):
print('names: ', xvg_file.names)
print('shape: ', xvg_file.array.shape)
print('names after: ', xvg_file.names)
print('shape after: ', xvg_file.array.shape)
xvg_filepath = 'test.txt'
pickle_filepath = 'test.pkl'
xvg_file = load_xvg(xvg_filepath)
print('names out: ', xvg_file.names)
print('shape out: ', xvg_file.array.shape)
test_fnc(xvg_file)
pickle.dump(xvg_file, open(pickle_filepath, 'wb'))
xvg_file = pickle.load(open(pickle_filepath, 'rb'))
print('\n2 out: ', xvg_file.names)
test_fnc(xvg_file)
os.remove(pickle_filepath)gives
names out: ['Temperature']
shape out: (2, 2)
names: ['Temperature']
shape: (2, 2)
names after: ['Temperature']
shape after: (2, 2)
2 out: ['Temperature']
names: ['Temperature']
shape: (2, 2)
names after: ['Temperature', 'Temperature']
shape after: (2, 2)
So, something wrong happens on the stage of either dumping or loading. It's also the case for cPickle and dill libs.
Reactions are currently unavailable