diff options
author | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2017-11-30 20:56:56 -0500 |
---|---|---|
committer | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2018-05-29 13:56:30 -0400 |
commit | 11e9d2aa469e6c5ed6fd6ccb29b139ea8e5e58b9 (patch) | |
tree | a09bde79ea597dacf05b3ae6e2e7da4b6bf4057e /numpy/matrixlib/defmatrix.py | |
parent | 6246cf19fdda3ccca4338dcec2f3956294e30ce7 (diff) | |
download | numpy-11e9d2aa469e6c5ed6fd6ccb29b139ea8e5e58b9.tar.gz |
DEP: give PendingDeprecationWarning for use of the matrix subclass.
Diffstat (limited to 'numpy/matrixlib/defmatrix.py')
-rw-r--r-- | numpy/matrixlib/defmatrix.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/numpy/matrixlib/defmatrix.py b/numpy/matrixlib/defmatrix.py index 9909fec8d..7baa401a8 100644 --- a/numpy/matrixlib/defmatrix.py +++ b/numpy/matrixlib/defmatrix.py @@ -3,6 +3,7 @@ from __future__ import division, absolute_import, print_function __all__ = ['matrix', 'bmat', 'mat', 'asmatrix'] import sys +import warnings import ast import numpy.core.numeric as N from numpy.core.numeric import concatenate, isscalar @@ -70,6 +71,10 @@ class matrix(N.ndarray): """ matrix(data, dtype=None, copy=True) + .. note:: It is no longer recommended to use this class, even for linear + algebra. Instead use regular arrays. The class may be removed + in the future. + Returns a matrix from an array-like object, or from a string of data. A matrix is a specialized 2-D array that retains its 2-D nature through operations. It has certain special operators, such as ``*`` @@ -105,6 +110,12 @@ class matrix(N.ndarray): """ __array_priority__ = 10.0 def __new__(subtype, data, dtype=None, copy=True): + warnings.warn('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) if isinstance(data, matrix): dtype2 = data.dtype if (dtype is None): |