summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-08-06 12:05:44 -0600
committerGitHub <noreply@github.com>2021-08-06 12:05:44 -0600
commit261a769dd135c1e4007a6d0bdbed68a8c929497a (patch)
tree6b4eef68ef2daac0edbd1e98b20ca8fd2f1bd162
parent2f52098908b00397e425904b89ac89d84e344627 (diff)
parent29fcb7facec5999a2011d2d4d4512f638050842f (diff)
downloadnumpy-261a769dd135c1e4007a6d0bdbed68a8c929497a.tar.gz
Merge pull request #19615 from rossbar/rm-deprecated-npyio-fns
MAINT: Proposal to expire three deprecated functions in numpy.lib.npyio
-rw-r--r--doc/release/upcoming_changes/19615.expired.rst8
-rw-r--r--numpy/__init__.pyi1
-rw-r--r--numpy/core/_add_newdocs.py2
-rw-r--r--numpy/lib/__init__.pyi1
-rw-r--r--numpy/lib/npyio.py69
-rw-r--r--numpy/lib/npyio.pyi6
-rw-r--r--numpy/lib/tests/test_io.py22
-rw-r--r--numpy/tests/test_public_api.py2
8 files changed, 11 insertions, 100 deletions
diff --git a/doc/release/upcoming_changes/19615.expired.rst b/doc/release/upcoming_changes/19615.expired.rst
new file mode 100644
index 000000000..4e02771e3
--- /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.
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index 0c6ac34f9..fb68f4a56 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 759a91d27..06f2a6376 100644
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -3252,7 +3252,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('dumps',
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 25640ec07..ae23b2ec4 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 b17d559d7..b8b3fe877 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -26,18 +26,9 @@ from numpy.compat import (
)
-@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',
+ 'savetxt', 'loadtxt', 'genfromtxt',
+ 'recfromtxt', 'recfromcsv', 'load', 'save', 'savez',
'savez_compressed', 'packbits', 'unpackbits', 'fromregex', 'DataSource'
]
@@ -2313,62 +2304,6 @@ _genfromtxt_with_like = array_function_dispatch(
)(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.
-
- .. 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 508357927..f69edd564 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): ...
@@ -98,7 +96,3 @@ def genfromtxt(
): ...
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 d97ad76df..02a9789a7 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -2503,28 +2503,6 @@ class TestPathUsage:
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:
- 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 6e4a8dee0..3fa2edd8f 100644
--- a/numpy/tests/test_public_api.py
+++ b/numpy/tests/test_public_api.py
@@ -45,8 +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',
- 'ndfromtxt': 'numpy.lib.npyio.ndfromtxt',
'recfromcsv': 'numpy.lib.npyio.recfromcsv',
'recfromtxt': 'numpy.lib.npyio.recfromtxt',
'safe_eval': 'numpy.lib.utils.safe_eval',