8000 DEP: add PendingDeprecation to matlib.py funky namespace by sethtroisi · Pull Request #15381 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DEP: add PendingDeprecation to matlib.py funky namespace #15381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions numpy/_pytesttester.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def __call__(self, label='fast', verbose=1, extra_argv=None,
# When testing matrices, ignore their PendingDeprecationWarnings
pytest_args += [
"-W ignore:the matrix subclass is not",
"-W ignore:Importing from numpy.matlib is",
]

if doctests:
Expand Down
15 changes: 14 additions & 1 deletion numpy/matlib.py
Original file line number Diff line number Diff line change
@@ -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__
Expand Down
8 changes: 0 additions & 8 deletions numpy/tests/test_matlib.py
Original file line number Diff line number Diff line change
@@ -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_
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
0