diff options
| author | Eric Wieser <wieser.eric@gmail.com> | 2017-06-30 22:05:06 +0100 |
|---|---|---|
| committer | Eric Wieser <wieser.eric@gmail.com> | 2017-06-30 22:28:07 +0100 |
| commit | a5322429c56fb2f906e49e4ae5b87533269d8150 (patch) | |
| tree | 8e4b5c5564ec1d53b3ba10ec16889c02d5c3955f /numpy/ma/core.py | |
| parent | 7254888b9ffe1f26ce59600ad31b7d4c9135c13d (diff) | |
| download | numpy-a5322429c56fb2f906e49e4ae5b87533269d8150.tar.gz | |
BUG: np.ma.masked does not preserve identity through pickle
It's still possible to create duplicate MaskedConstants through `.copy()`
Diffstat (limited to 'numpy/ma/core.py')
| -rw-r--r-- | numpy/ma/core.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 2c62019cd..5cf859b75 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -6190,8 +6190,12 @@ class MaskedConstant(MaskedArray): _mask = mask = np.array(True) _baseclass = ndarray + __singleton = None + def __new__(self): - return self._data.view(self) + if self.__singleton is None: + self.__singleton = self._data.view(self) + return self.__singleton def __array_finalize__(self, obj): return |
