I found many threads about this, but the problem with all of them is the namespace. My problem has nothing to do with the namespace.
A small example:
import cPickle as pickle from uncertainties import Variable class value(Variable): def __init__(self, args, showing=False): self.show = showing Variable.__init__(self, args[0], args[1]) val = value((3,1), True) print val.nominal_value, val.std_dev(), val.show fobj = file("pickle.file", "w") pickle.dump(val, fobj) fobj.close() fobj = file("pickle.file", "r") val = pickle.load(fobj) fobj.close() print val.nominal_value, val.std_dev(), val.show
Result of this code:
3.0 1.0 True 3.0 1.0 --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(fname, *where) 173 else: 174 filename = fname --> 175 __builtin__.execfile(filename, *where) /home/markus/pickle.py in <module>() 19 val = pickle.load(fobj) 20 fobj.close() ---> 21 print val.nominal_value, val.std_dev(), val.show AttributeError: 'value' object has no attribute 'show'
The namespace is the same when pickled and scattered. All uncertainties.Variable attributes are restored - only my added one “show” is skipped.
source share