summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorkritisingh1 <kritisingh1.ks@gmail.com>2019-04-03 22:55:50 +0530
committerkritisingh1 <kritisingh1.ks@gmail.com>2019-04-05 19:32:18 +0530
commit4c35a853c2a09de5bdb236aa6bd97aa5ea18f195 (patch)
treef2a30746bf8d4da88791f4328146bccdee34bd95 /numpy
parent91a93ad54d6f5d8476f2af046b2895ef81e48c15 (diff)
downloadnumpy-4c35a853c2a09de5bdb236aa6bd97aa5ea18f195.tar.gz
Issue deprecation warnings
Diffstat (limited to 'numpy')
-rw-r--r--numpy/lib/npyio.py14
-rw-r--r--numpy/lib/tests/test_io.py6
-rw-r--r--numpy/lib/utils.py6
3 files changed, 24 insertions, 2 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index d702859fa..460c2f5f2 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -2225,6 +2225,9 @@ def ndfromtxt(fname, **kwargs):
"""
Load ASCII data stored in a file and return it as a single array.
+ .. deprecated:: 1.17
+ np.ndfromtxt is deprecated
+
Parameters
----------
fname, kwargs : For a description of input parameters, see `genfromtxt`.
@@ -2235,6 +2238,10 @@ def ndfromtxt(fname, **kwargs):
"""
kwargs['usemask'] = False
+ # Numpy 1.17
+ warnings.warn(
+ "np.ndfromtxt is deprecated",
+ DeprecationWarning, stacklevel=2)
return genfromtxt(fname, **kwargs)
@@ -2242,6 +2249,9 @@ def mafromtxt(fname, **kwargs):
"""
Load ASCII data stored in a text file and return a masked array.
+ .. deprecated:: 1.17
+ np.mafromtxt is deprecated
+
Parameters
----------
fname, kwargs : For a description of input parameters, see `genfromtxt`.
@@ -2252,6 +2262,10 @@ def mafromtxt(fname, **kwargs):
"""
kwargs['usemask'] = True
+ # Numpy 1.17
+ warnings.warn(
+ "np.mafromtxt is deprecated",
+ DeprecationWarning, stacklevel=2)
return genfromtxt(fname, **kwargs)
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index 7ef25538b..afad803db 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -2369,7 +2369,8 @@ class TestPathUsage(object):
control = np.array([[1, 2], [3, 4]], dtype=int)
test = np.ndfromtxt(path, dtype=int)
- assert_array_equal(test, control)
+ with assert_warns(VisibleDeprecationWarning):
+ assert_array_equal(test, control)
def test_mafromtxt(self):
# From `test_fancy_dtype_alt` above
@@ -2380,7 +2381,8 @@ class TestPathUsage(object):
test = np.mafromtxt(path, delimiter=',')
control = ma.array([(1.0, 2.0, 3.0), (4.0, 5.0, 6.0)])
- assert_equal(test, control)
+ with assert_warns(VisibleDeprecationWarning):
+ assert_equal(test, control)
def test_recfromtxt(self):
with temppath(suffix='.txt') as path:
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index 718b55c4b..188a99d92 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -1098,6 +1098,9 @@ def safe_eval(source):
Evaluate a string containing a Python literal expression without
allowing the execution of arbitrary non-literal code.
+ .. deprecate:: 1.17
+ safe_eval is deprecated
+
Parameters
----------
source : str
@@ -1137,6 +1140,9 @@ def safe_eval(source):
# Local import to speed up numpy's import time.
import ast
+ # Numpy 1.17
+ warnings.warn("SafeEval is deprecated in 1.17",
+ DeprecationWarning, stacklevel=2)
return ast.literal_eval(source)