diff options
-rw-r--r-- | numpy/ma/core.py | 6 | ||||
-rw-r--r-- | numpy/ma/tests/test_core.py | 10 |
2 files changed, 16 insertions, 0 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index a57cdf5c1..a6f252067 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -5718,6 +5718,12 @@ class MaskedConstant(MaskedArray): def flatten(self): return masked_array([self._data], dtype=float, mask=[True]) + def __reduce__(self): + """Override of MaskedArray's __reduce__. + """ + return (self.__class__, ()) + + masked = masked_singleton = MaskedConstant() diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 0175c1213..58f81b071 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -385,6 +385,16 @@ class TestMaskedArray(TestCase): assert_equal(a_pickled, a) self.assertTrue(isinstance(a_pickled._data, np.matrix)) + def test_pickling_maskedconstant(self): + "Test pickling MaskedConstant" + + import cPickle + mc = np.ma.masked + mc_pickled = cPickle.loads(mc.dumps()) + assert_equal(mc_pickled._baseclass, mc._baseclass) + assert_equal(mc_pickled._mask, mc._mask) + assert_equal(mc_pickled._data, mc._data) + def test_pickling_wstructured(self): "Tests pickling w/ structured array" import cPickle |