diff options
| author | Seth Troisi <sethtroisi@google.com> | 2020-01-22 21:54:01 -0800 |
|---|---|---|
| committer | Seth Troisi <sethtroisi@google.com> | 2020-01-23 15:14:59 -0800 |
| commit | 581f1664cc24290f1257484cf2ce4df296adfb20 (patch) | |
| tree | fa4d333c075f40f6a6e5f9015e4255cc6b6ea629 /numpy | |
| parent | 2dadfe8c6158b3f4ccdac3d044a2b6b8b91397eb (diff) | |
| download | numpy-581f1664cc24290f1257484cf2ce4df296adfb20.tar.gz | |
DEP: deprecate importing numpy/matrixlib.py
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/_pytesttester.py | 1 | ||||
| -rw-r--r-- | numpy/matlib.py | 11 | ||||
| -rw-r--r-- | numpy/tests/test_matlib.py | 8 |
3 files changed, 12 insertions, 8 deletions
diff --git a/numpy/_pytesttester.py b/numpy/_pytesttester.py index e573d53ab..0dc38fa59 100644 --- a/numpy/_pytesttester.py +++ b/numpy/_pytesttester.py @@ -153,6 +153,7 @@ class PytestTester: # When testing matrices, ignore their PendingDeprecationWarnings pytest_args += [ "-W ignore:the matrix subclass is not", + "-W ignore:Importing from numpy.matlib is", ] if doctests: diff --git a/numpy/matlib.py b/numpy/matlib.py index 5e53f74d9..bd6b63289 100644 --- a/numpy/matlib.py +++ b/numpy/matlib.py @@ -1,3 +1,14 @@ +import warnings + +# 2018-05-29, PendingDeprecationWarning added to matrix.__new__ +# 2020-01-23, numpy 1.19.0 PendingDeprecatonWarning +warnings.warn("Importing from numpy.matlib is deprecated since 1.19.0. " + "The matrix subclass is not the recommended way to represent " + "matrices or deal with linear algebra (see " + "https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). " + "Please adjust your code to use regular ndarray. ", + PendingDeprecationWarning, stacklevel=2) + import numpy as np from numpy.matrixlib.defmatrix import matrix, asmatrix # Matlib.py contains all functions in the numpy namespace with a few diff --git a/numpy/tests/test_matlib.py b/numpy/tests/test_matlib.py index e04947a2e..0e93c4848 100644 --- a/numpy/tests/test_matlib.py +++ b/numpy/tests/test_matlib.py @@ -1,11 +1,3 @@ -# As we are testing matrices, we ignore its PendingDeprecationWarnings -try: - import pytest - pytestmark = pytest.mark.filterwarnings( - 'ignore:the matrix subclass is not:PendingDeprecationWarning') -except ImportError: - pass - import numpy as np import numpy.matlib from numpy.testing import assert_array_equal, assert_ |
