Closed GoogleCodeExporter closed 8 years ago
Currently we are stuck to make DataSet
a new style class. This breaks reading in pickle files. See also #19 #20 #45 #46
Here is a possible way out: we write a dump method that does something like
with os.open('dump_file') as f:
f.write(repr(self.__dict__))
It may be a little more complicated, that is, we may need to copy and modify __dict__
and/or the result of repr
for this specific need before to dump it. A quick try on a Python shell
>>> ds
DataSet(random_search on f6 2-D)
>>> dss = cma._BlancClass()
>>> len(dss.__dict__)
0
>>> dss.__dict__ = eval(repr(ds.__dict__))
NameError: name 'nan' is not defined
>>> nan = np.nan
>>> dss.__dict__ = eval(repr(ds.__dict__))
>>> len(ds.__dict__), len(dss.__dict__)
(20, 20)
suggests that only array
and nan
needs to be defined to succeed with eval(repr(self.__dict__))
. However, repr
writes floats apparently with limited precision. That is, the data are not exactly the same. AFAICS, this is not a major problem for our use case.
If we now create dss
as DataSet
from some arbitrary (but valid) input arguments first, we should be good.
Another entry point of investigation is JSON.
We don't use pickle files any more.
Original issue reported on code.google.com by
dimo.bro...@inria.fr
on 16 Jun 2014 at 1:02