From 3c9e27907d6f4b0b88cb7464cc19f9f08a63b83e Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Thu, 5 Aug 2021 13:40:34 +0300 Subject: [PATCH 1/4] Rm numpy.lib.npyio.loads. --- numpy/__init__.pyi | 1 - numpy/core/_add_newdocs.py | 2 +- numpy/lib/__init__.pyi | 1 - numpy/lib/npyio.py | 11 +---------- numpy/lib/npyio.pyi | 2 -- 5 files changed, 2 insertions(+), 15 deletions(-) diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 0c6ac34f990..fb68f4a566c 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -516,7 +516,6 @@ from numpy.lib.npyio import ( recfromtxt as recfromtxt, recfromcsv as recfromcsv, load as load, - loads as loads, save as save, savez as savez, savez_compressed as savez_compressed, diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py index 759a91d270e..06f2a6376fa 100644 --- a/numpy/core/_add_newdocs.py +++ b/numpy/core/_add_newdocs.py @@ -3252,7 +3252,7 @@ a.dumps() Returns the pickle of the array as a string. - pickle.loads or numpy.loads will convert the string back to an array. + pickle.loads will convert the string back to an array. Parameters ---------- diff --git a/numpy/lib/__init__.pyi b/numpy/lib/__init__.pyi index 25640ec072d..ae23b2ec498 100644 --- a/numpy/lib/__init__.pyi +++ b/numpy/lib/__init__.pyi @@ -130,7 +130,6 @@ from numpy.lib.npyio import ( recfromtxt as recfromtxt, recfromcsv as recfromcsv, load as load, - loads as loads, save as save, savez as savez, savez_compressed as savez_compressed, diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 3b6a1c563a9..58133056f52 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -26,18 +26,9 @@ ) -@set_module('numpy') -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', - 'recfromtxt', 'recfromcsv', 'load', 'loads', 'save', 'savez', + 'recfromtxt', 'recfromcsv', 'load', 'save', 'savez', 'savez_compressed', 'packbits', 'unpackbits', 'fromregex', 'DataSource' ] diff --git a/numpy/lib/npyio.pyi b/numpy/lib/npyio.pyi index 508357927b7..407175661ce 100644 --- a/numpy/lib/npyio.pyi +++ b/numpy/lib/npyio.pyi @@ -11,8 +11,6 @@ from numpy.core.multiarray import ( __all__: List[str] -def loads(*args, **kwargs): ... - class BagObj: def __init__(self, obj): ... def __getattribute__(self, key): ... From fe6e3afc2862a2734077c3d41d31470c3addc70b Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Thu, 5 Aug 2021 13:48:43 +0300 Subject: [PATCH 2/4] Rm numpy.lib.npyio.ndfromtxt. --- numpy/lib/npyio.py | 30 +----------------------------- numpy/lib/npyio.pyi | 1 - numpy/lib/tests/test_io.py | 11 ----------- numpy/tests/test_public_api.py | 1 - 4 files changed, 1 insertion(+), 42 deletions(-) diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 58133056f52..08abac0bacc 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -27,7 +27,7 @@ __all__ = [ - 'savetxt', 'loadtxt', 'genfromtxt', 'ndfromtxt', 'mafromtxt', + 'savetxt', 'loadtxt', 'genfromtxt', 'mafromtxt', 'recfromtxt', 'recfromcsv', 'load', 'save', 'savez', 'savez_compressed', 'packbits', 'unpackbits', 'fromregex', 'DataSource' ] @@ -2301,34 +2301,6 @@ def encode_unicode_cols(row_tup): )(genfromtxt) -def ndfromtxt(fname, **kwargs): - """ - Load ASCII data stored in a file and return it as a single array. - - .. deprecated:: 1.17 - ndfromtxt` is a deprecated alias of `genfromtxt` which - overwrites the ``usemask`` argument with `False` even when - explicitly called as ``ndfromtxt(..., usemask=True)``. - Use `genfromtxt` instead. - - Parameters - ---------- - fname, kwargs : For a description of input parameters, see `genfromtxt`. - - See Also - -------- - numpy.genfromtxt : generic function. - - """ - kwargs['usemask'] = False - # Numpy 1.17 - warnings.warn( - "np.ndfromtxt is a deprecated alias of np.genfromtxt, " - "prefer the latter.", - DeprecationWarning, stacklevel=2) - return genfromtxt(fname, **kwargs) - - def mafromtxt(fname, **kwargs): """ Load ASCII data stored in a text file and return a masked array. diff --git a/numpy/lib/npyio.pyi b/numpy/lib/npyio.pyi index 407175661ce..22e689d790b 100644 --- a/numpy/lib/npyio.pyi +++ b/numpy/lib/npyio.pyi @@ -98,5 +98,4 @@ def recfromtxt(fname, **kwargs): ... def recfromcsv(fname, **kwargs): ... # NOTE: Deprecated -# def ndfromtxt(fname, **kwargs): ... # def mafromtxt(fname, **kwargs): ... diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index d97ad76dfd0..aa0037d32c6 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -2503,17 +2503,6 @@ def test_genfromtxt(self): data = np.genfromtxt(path) assert_array_equal(a, data) - def test_ndfromtxt(self): - # Test outputting a standard ndarray - with temppath(suffix='.txt') as path: - path = Path(path) - with path.open('w') as f: - f.write(u'1 2\n3 4') - - control = np.array([[1, 2], [3, 4]], dtype=int) - test = np.genfromtxt(path, dtype=int) - assert_array_equal(test, control) - def test_mafromtxt(self): # From `test_fancy_dtype_alt` above with temppath(suffix='.txt') as path: diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py index 6e4a8dee0a7..a40275eb719 100644 --- a/numpy/tests/test_public_api.py +++ b/numpy/tests/test_public_api.py @@ -46,7 +46,6 @@ def test_numpy_namespace(): 'get_array_wrap': 'numpy.lib.shape_base.get_array_wrap', 'get_include': 'numpy.lib.utils.get_include', 'mafromtxt': 'numpy.lib.npyio.mafromtxt', - 'ndfromtxt': 'numpy.lib.npyio.ndfromtxt', 'recfromcsv': 'numpy.lib.npyio.recfromcsv', 'recfromtxt': 'numpy.lib.npyio.recfromtxt', 'safe_eval': 'numpy.lib.utils.safe_eval', From 76639cc60a6a4ee0d7ca3dd1746c2c16367fb154 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Thu, 5 Aug 2021 13:52:34 +0300 Subject: [PATCH 3/4] Rm numpy.lib.npyio.mafromtxt. --- numpy/lib/npyio.py | 30 +----------------------------- numpy/lib/npyio.pyi | 3 --- numpy/lib/tests/test_io.py | 11 ----------- numpy/tests/test_public_api.py | 1 - 4 files changed, 1 insertion(+), 44 deletions(-) diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 08abac0bacc..d8adc3cdfc5 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -27,7 +27,7 @@ __all__ = [ - 'savetxt', 'loadtxt', 'genfromtxt', 'mafromtxt', + 'savetxt', 'loadtxt', 'genfromtxt', 'recfromtxt', 'recfromcsv', 'load', 'save', 'savez', 'savez_compressed', 'packbits', 'unpackbits', 'fromregex', 'DataSource' ] @@ -2301,34 +2301,6 @@ def encode_unicode_cols(row_tup): )(genfromtxt) -def mafromtxt(fname, **kwargs): - """ - Load ASCII data stored in a text file and return a masked array. - - .. deprecated:: 1.17 - np.mafromtxt is a deprecated alias of `genfromtxt` which - overwrites the ``usemask`` argument with `True` even when - explicitly called as ``mafromtxt(..., usemask=False)``. - Use `genfromtxt` instead. - - Parameters - ---------- - fname, kwargs : For a description of input parameters, see `genfromtxt`. - - See Also - -------- - numpy.genfromtxt : generic function to load ASCII data. - - """ - kwargs['usemask'] = True - # Numpy 1.17 - warnings.warn( - "np.mafromtxt is a deprecated alias of np.genfromtxt, " - "prefer the latter.", - DeprecationWarning, stacklevel=2) - return genfromtxt(fname, **kwargs) - - def recfromtxt(fname, **kwargs): """ Load ASCII data from a file and return it in a record array. diff --git a/numpy/lib/npyio.pyi b/numpy/lib/npyio.pyi index 22e689d790b..f69edd5645e 100644 --- a/numpy/lib/npyio.pyi +++ b/numpy/lib/npyio.pyi @@ -96,6 +96,3 @@ def genfromtxt( ): ... def recfromtxt(fname, **kwargs): ... def recfromcsv(fname, **kwargs): ... - -# NOTE: Deprecated -# def mafromtxt(fname, **kwargs): ... diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index aa0037d32c6..02a9789a7db 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -2503,17 +2503,6 @@ def test_genfromtxt(self): data = np.genfromtxt(path) assert_array_equal(a, data) - def test_mafromtxt(self): - # From `test_fancy_dtype_alt` above - with temppath(suffix='.txt') as path: - path = Path(path) - with path.open('w') as f: - f.write(u'1,2,3.0\n4,5,6.0\n') - - test = np.genfromtxt(path, delimiter=',', usemask=True) - control = ma.array([(1.0, 2.0, 3.0), (4.0, 5.0, 6.0)]) - assert_equal(test, control) - def test_recfromtxt(self): with temppath(suffix='.txt') as path: path = Path(path) diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py index a40275eb719..3fa2edd8f4a 100644 --- a/numpy/tests/test_public_api.py +++ b/numpy/tests/test_public_api.py @@ -45,7 +45,6 @@ def test_numpy_namespace(): 'fastCopyAndTranspose': 'numpy.core._multiarray_umath._fastCopyAndTranspose', 'get_array_wrap': 'numpy.lib.shape_base.get_array_wrap', 'get_include': 'numpy.lib.utils.get_include', - 'mafromtxt': 'numpy.lib.npyio.mafromtxt', 'recfromcsv': 'numpy.lib.npyio.recfromcsv', 'recfromtxt': 'numpy.lib.npyio.recfromtxt', 'safe_eval': 'numpy.lib.utils.safe_eval', From 29fcb7facec5999a2011d2d4d4512f638050842f Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Thu, 5 Aug 2021 15:49:09 +0300 Subject: [PATCH 4/4] Add release note. --- doc/release/upcoming_changes/19615.expired.rst | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 doc/release/upcoming_changes/19615.expired.rst diff --git a/doc/release/upcoming_changes/19615.expired.rst b/doc/release/upcoming_changes/19615.expired.rst new file mode 100644 index 00000000000..4e02771e3ad --- /dev/null +++ b/doc/release/upcoming_changes/19615.expired.rst @@ -0,0 +1,8 @@ +Expired deprecations for ``loads``, ``ndfromtxt``, and ``mafromtxt`` in npyio +----------------------------------------------------------------------------- + +``numpy.loads`` was deprecated in v1.15, with the recommendation that users +use `pickle.loads` instead. +``ndfromtxt`` and ``mafromtxt`` were both deprecated in v1.17 - users should +use `numpy.genfromtxt` instead with the appropriate value for the +``usemask`` parameter.