thouis / numpy-trac-migration

numpy Trac to github issues migration
2 stars 3 forks source link

pickle with masked array (Trac #2175) #5965

Open numpy-gitbot opened 12 years ago

numpy-gitbot commented 12 years ago

Original ticket http://projects.scipy.org/numpy/ticket/2175 on 2012-06-21 by trac user eyurtsev, assigned to unknown.

An error message comes up when I try to pickle the result of numpy.mean on a masked array of nans.

I suspect that this is a bug.

For convenience a python file is attached with this code.


import pickle import numpy

a = numpy.mean(numpy.ma.masked_invalid(numpy.nan))

with open('test.txt', 'wb') as f: pickle.dump(a, f)

-------------- Error Message --------------------

/usr/lib/python2.7/pickle.pyc in save(self, obj) 304 reduce = getattr(obj, "reduce_ex", None) 305 if reduce: --> 306 rv = reduce(self.proto) 307 else: 308 reduce = getattr(obj, "reduce", None)

/usr/lib/python2.7/dist-packages/numpy/ma/core.pyc in reduce(self) 5471 return (_mareconstruct, 5472 (self.class, self._baseclass, (0,), 'b',), -> 5473 self.getstate()) 5474 #

5475 def deepcopy(self, memo=None):

/usr/lib/python2.7/dist-packages/numpy/ma/core.pyc in getstate(self) 5444 getmaskarray(self).tostring(cf), 5445 #getmaskarray(self).tolist(),

-> 5446 self._fill_value, 5447 ) 5448 return state

AttributeError: 'MaskedConstant' object has no attribute '_fill_value'

numpy-gitbot commented 12 years ago

Attachment added by trac user eyurtsev on 2012-06-21: masked_test.py