Skip to content

Commit 581f166

Browse files
committed
DEP: deprecate importing numpy/matrixlib.py
1 parent 2dadfe8 commit 581f166

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

numpy/_pytesttester.py

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def __call__(self, label='fast', verbose=1, extra_argv=None,
153153
# When testing matrices, ignore their PendingDeprecationWarnings
154154
pytest_args += [
155155
"-W ignore:the matrix subclass is not",
156+
"-W ignore:Importing from numpy.matlib is",
156157
]
157158

158159
if doctests:

numpy/matlib.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
import warnings
2+
3+
# 2018-05-29, PendingDeprecationWarning added to matrix.__new__
4+
# 2020-01-23, numpy 1.19.0 PendingDeprecatonWarning
5+
warnings.warn("Importing from numpy.matlib is deprecated since 1.19.0. "
6+
"The matrix subclass is not the recommended way to represent "
7+
"matrices or deal with linear algebra (see "
8+
"https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). "
9+
"Please adjust your code to use regular ndarray. ",
10+
PendingDeprecationWarning, stacklevel=2)
11+
112
import numpy as np
213
from numpy.matrixlib.defmatrix import matrix, asmatrix
314
# Matlib.py contains all functions in the numpy namespace with a few

numpy/tests/test_matlib.py

-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
# As we are testing matrices, we ignore its PendingDeprecationWarnings
2-
try:
3-
import pytest
4-
pytestmark = pytest.mark.filterwarnings(
5-
'ignore:the matrix subclass is not:PendingDeprecationWarning')
6-
except ImportError:
7-
pass
8-
91
import numpy as np
102
import numpy.matlib
113
from numpy.testing import assert_array_equal, assert_

pytest.ini

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ filterwarnings =
1313
ignore::UserWarning:cpuinfo,
1414
# Matrix PendingDeprecationWarning.
1515
ignore:the matrix subclass is not
16+
ignore:Importing from numpy.matlib is
1617

1718
env =
1819
PYTHONHASHSEED=0

0 commit comments

Comments
 (0)