diff options
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/numeric.py | 12 | ||||
| -rw-r--r-- | numpy/core/tests/test_multiarray.py | 5 | ||||
| -rw-r--r-- | numpy/lib/npyio.py | 9 | ||||
| -rw-r--r-- | numpy/ma/core.py | 14 |
4 files changed, 36 insertions, 4 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index ac64b0537..431467a5a 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -42,7 +42,13 @@ else: import cPickle as pickle import __builtin__ as builtins -loads = pickle.loads + +def loads(*args, **kwargs): + # NumPy 1.15.0, 2017-12-10 + warnings.warn( + "np.core.numeric.loads is deprecated, use pickle.loads instead", + DeprecationWarning, stacklevel=2) + return pickle.loads(*args, **kwargs) __all__ = [ @@ -2134,6 +2140,10 @@ def load(file): load, save """ + # NumPy 1.15.0, 2017-12-10 + warnings.warn( + "np.core.numeric.load is deprecated, use pickle.load instead", + DeprecationWarning, stacklevel=2) if isinstance(file, type("")): file = open(file, "rb") return pickle.load(file) diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index e54d67a0d..4575ac8e2 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -3434,10 +3434,11 @@ class TestPickling(object): assert_equal(a, pickle.loads(a.dumps()), err_msg="%r" % a) def _loads(self, obj): + import pickle if sys.version_info[0] >= 3: - return np.loads(obj, encoding='latin1') + return pickle.loads(obj, encoding='latin1') else: - return np.loads(obj) + return pickle.loads(obj) # version 0 pickles, using protocol=2 to pickle # version 0 doesn't have a version field diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index e4d827334..7b51cb9c7 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -30,7 +30,14 @@ else: import cPickle as pickle from future_builtins import map -loads = pickle.loads + +def loads(*args, **kwargs): + # NumPy 1.15.0, 2017-12-10 + warnings.warn( + "np.loads is deprecated, use pickle.loads instead", + DeprecationWarning, stacklevel=2) + return pickle.loads(*args, **kwargs) + __all__ = [ 'savetxt', 'loadtxt', 'genfromtxt', 'ndfromtxt', 'mafromtxt', 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) |
