[NumPy-Tickets] [NumPy] #2175: pickle with masked array

NumPy Trac numpy-tickets@scipy....
Thu Jun 21 15:32:58 CDT 2012


#2175: pickle with masked array
----------------------+-----------------------------------------------------
 Reporter:  eyurtsev  |       Owner:  somebody   
     Type:  defect    |      Status:  new        
 Priority:  low       |   Milestone:  Unscheduled
Component:  Other     |     Version:  1.6.1      
 Keywords:            |  
----------------------+-----------------------------------------------------
 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'

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/2175>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list