One solution is to change names just before we pickle, then change
back after unpickling.
saveData = Data
Data = saveData.__class__
should restore sanity, and allow:
pickle.dump(saveData, file)
It is a pretty crude hack, however, and as Gary says, raises lots of
questions as to what will happen if a state is loaded on top of the
existing, etc...
I've tried the suggestion but the unit test gives:
======================================================================
ERROR: The pickling and saving of the relax data storage singleton.
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/nmr5/edau/relax/relax-1.3/test_suite/unit_tests/state_testing_base.py",
line 104, in test_save
self.state.save_state(state=self.tmp_file)
File "/nmr5/edau/relax/relax-1.3/generic_fns/state.py", line 77, in
save_state
save_store = relax_data_store
UnboundLocalError: local variable 'relax_data_store' referenced before
assignment
======================================================================
Can you show me the context of this error - UnboundLocal looks to me
like an implimentation issue rather than a fundamental problem with
the approach.
Removing the line 'Data = saveData.__class__' gives:
======================================================================
ERROR: The pickling and saving of the relax data storage singleton.
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/nmr5/edau/relax/relax-1.3/test_suite/unit_tests/state_testing_base.py",
line 104, in test_save
self.state.save_state(state=self.tmp_file)
File "/nmr5/edau/relax/relax-1.3/generic_fns/state.py", line 80, in
save_state
dump(save_store, file, 1)
PicklingError: Can't pickle <class 'data.Data'>: it's not the same
object as data.Data
======================================================================
Yes, I guessed that bit would be important!
Chris