diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-12-10 10:08:44 -0800 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-12-10 17:25:38 -0800 |
commit | b023d734eeec42a2a1064eaed4de12fd676f1de0 (patch) | |
tree | 39530c07f73d770c77c00dba45c085b7fb36fd19 /numpy/ma | |
parent | 5c16f535e7515c2394b19cc6778ad9b5ae24d729 (diff) | |
download | numpy-b023d734eeec42a2a1064eaed4de12fd676f1de0.tar.gz |
DEP: Deprecate the pickle aliases
* The np.ma functions are misleading, as they do not actually do anything special for ma.array
* The np.loads functions doesn't even have numpy-specific documentation, and does not behave consistently with `np.load`
* The string overloads of np.ma.load and np.ma.dump do not work well on python 3, as they make assumptions about whether a binary or text pickle file is used (gh-5491)
Diffstat (limited to 'numpy/ma')
-rw-r--r-- | numpy/ma/core.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 407869362..04c1c1a6a 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -7859,6 +7859,16 @@ def asanyarray(a, dtype=None): ############################################################################## # Pickling # ############################################################################## + +def _pickle_warn(method): + # NumPy 1.15.0, 2017-12-10 + warnings.warn( + "np.ma.{method} is deprecated, use pickle.{method} instead" + .format(method), + DeprecationWarning, + stacklevel=3) + + def dump(a, F): """ Pickle a masked array to a file. @@ -7873,6 +7883,7 @@ def dump(a, F): The file to pickle `a` to. If a string, the full path to the file. """ + _pickle_warn('dump') if not hasattr(F, 'readline'): with open(F, 'w') as F: pickle.dump(a, F) @@ -7893,6 +7904,7 @@ def dumps(a): returned. """ + _pickle_warn('dumps') return pickle.dumps(a) @@ -7916,6 +7928,7 @@ def load(F): the NumPy binary .npy format. """ + _pickle_warn('load') if not hasattr(F, 'readline'): with open(F, 'r') as F: pickle.load(F) @@ -7939,6 +7952,7 @@ def loads(strg): dumps : Return a string corresponding to the pickling of a masked array. """ + _pickle_warn('loads') return pickle.loads(strg) |