diff options
author | Matti Picus <matti.picus@gmail.com> | 2020-01-27 14:27:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-27 14:27:26 +0200 |
commit | ae5d91167db79376fef9244542b2a2073521f2be (patch) | |
tree | 8e7928279432af7b567677b4d05d65fa70b9ae47 | |
parent | af931b9c37935a9b549c2ef33c8e851c3dd2258e (diff) | |
parent | 581f1664cc24290f1257484cf2ce4df296adfb20 (diff) | |
download | numpy-ae5d91167db79376fef9244542b2a2073521f2be.tar.gz |
Merge pull request #15381 from sethtroisi/matlib_namespace
DEP: add PendingDeprecation to matlib.py funky namespace
-rw-r--r-- | numpy/_pytesttester.py | 1 | ||||
-rw-r--r-- | numpy/matlib.py | 15 | ||||
-rw-r--r-- | numpy/tests/test_matlib.py | 8 | ||||
-rw-r--r-- | pytest.ini | 1 |
4 files changed, 16 insertions, 9 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 1f0345be4..bd6b63289 100644 --- a/numpy/matlib.py +++ b/numpy/matlib.py @@ -1,6 +1,19 @@ +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 -# need * as we're copying the numpy namespace (FIXME: this makes little sense) +# Matlib.py contains all functions in the numpy namespace with a few +# replacements. See doc/source/reference/routines.matlib.rst for details. +# Need * as we're copying the numpy namespace. from numpy import * # noqa: F403 __version__ = np.__version__ 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_ diff --git a/pytest.ini b/pytest.ini index 480130337..0db7f80dd 100644 --- a/pytest.ini +++ b/pytest.ini @@ -13,6 +13,7 @@ filterwarnings = ignore::UserWarning:cpuinfo, # Matrix PendingDeprecationWarning. ignore:the matrix subclass is not + ignore:Importing from numpy.matlib is env = PYTHONHASHSEED=0 |