<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/2175" rel="nofollow">http://projects.scipy.org/numpy/ticket/2175</a> on 2012-06-21 by trac user eyurtsev, assigned to unknown.</em></p>
<p dir="auto">An error message comes up when I try to pickle the result of<br>
numpy.mean on a masked array of nans.</p>
<p dir="auto">I suspect that this is a bug.</p>
<p dir="auto">For convenience a python file is attached with this code.</p>
<hr>
<p dir="auto">import pickle<br>
import numpy</p>
<p dir="auto">a = numpy.mean(numpy.ma.masked_invalid(numpy.nan))</p>
<p dir="auto">with open('test.txt', 'wb') as f:<br>
pickle.dump(a, f)</p>
<p dir="auto">-------------- Error Message --------------------</p>
<p dir="auto">/usr/lib/python2.7/pickle.pyc in save(self, obj)<br>
304             reduce = getattr(obj, "<strong>reduce_ex</strong>", None)<br>
305             if reduce:<br>
--&gt; 306                 rv = reduce(self.proto)<br>
307             else:<br>
308                 reduce = getattr(obj, "<strong>reduce</strong>", None)</p>
<p dir="auto">/usr/lib/python2.7/dist-packages/numpy/ma/core.pyc in <strong>reduce</strong>(self)<br>
5471         return (_mareconstruct,<br>
5472                 (self.<strong>class</strong>, self._baseclass, (0,), 'b',),<br>
-&gt; 5473                 self.<strong>getstate</strong>())<br>
5474     #</p>
<p dir="auto">5475     def <strong>deepcopy</strong>(self, memo=None):</p>
<p dir="auto">/usr/lib/python2.7/dist-packages/numpy/ma/core.pyc in <strong>getstate</strong>(self)<br>
5444                  getmaskarray(self).tostring(cf),<br>
5445                  #getmaskarray(self).tolist(),</p>
<p dir="auto">-&gt; 5446                  self._fill_value,<br>
5447                  )<br>
5448         return state</p>
<p dir="auto">AttributeError: 'MaskedConstant' object has no attribute '_fill_value'</p>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/2155" rel="nofollow">http://projects.scipy.org/numpy/ticket/2155</a> on 2012-06-11 by trac user r0k3, assigned to <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pierregm/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pierregm">@pierregm</a>.</em></p>
<p dir="auto">One gets an error while trying to pickle an object that contains a MaskedConstant.</p>