← Back to team overview

python-quantities-developers team mailing list archive

[Bug 406119] Re: Pickle strips units

 

** Changed in: python-quantities
       Status: New => Confirmed

** Changed in: python-quantities
   Importance: Undecided => Critical

** Changed in: python-quantities
     Assignee: (unassigned) => Darren Dale (dsdale24)

** Changed in: python-quantities
    Milestone: None => 0.5.0

-- 
Pickle strips units
https://bugs.launchpad.net/bugs/406119
You received this bug notification because you are a member of Python
Quantities Development Team, which is subscribed to python-quantities.

Status in Physical Quantities for Python: Confirmed

Bug description:
It seems as though the units are striped from Quantity objects during the pickling/unpickling process. 
Note: i'm new to python so perhaps I simply do not understand the how the pickle module is supposed to work. 

----------------------------------------
Code: 
----------------------------------------
import quantities as quant
import cPickle

quan1 = quant.Quantity([1,3,4,5],'s')
file = open('/Users/psilentp/qfile.cPkl','wb')
cPickle.dump(quan1,file)
file.close()
file2 = open('/Users/psilentp/qfile.cpkl','rb')
quan2 = cPickle.load(file2)
file2.close()

print(quan1)
print(quan2)

------------------------------------------------
output
------------------------------------------------
run /Users/psilentp/pybin/quanttest.py
[1 3 4 5] s
[1 3 4 5] dimensionless