diff options
author | melissawm <melissawm@gmail.com> | 2021-02-05 14:05:34 -0300 |
---|---|---|
committer | melissawm <melissawm@gmail.com> | 2021-02-05 14:17:42 -0300 |
commit | 46b5b0d428bbe3216140e799ca4aaa2507b8293e (patch) | |
tree | 8f0cb39882a0f3d4ed2ad887bd2c627dd432bb54 | |
parent | 0a1bd4ead41b1fdfb53142097b5e08555f280545 (diff) | |
download | numpy-46b5b0d428bbe3216140e799ca4aaa2507b8293e.tar.gz |
DOC: Discussion on the @ operator and the matrix class
-rw-r--r-- | doc/source/reference/arrays.classes.rst | 2 | ||||
-rw-r--r-- | doc/source/reference/arrays.ndarray.rst | 6 | ||||
-rw-r--r-- | doc/source/reference/routines.linalg.rst | 16 | ||||
-rw-r--r-- | numpy/core/code_generators/ufunc_docstrings.py | 2 |
4 files changed, 22 insertions, 4 deletions
diff --git a/doc/source/reference/arrays.classes.rst b/doc/source/reference/arrays.classes.rst index 3a4ed2168..92c271f6b 100644 --- a/doc/source/reference/arrays.classes.rst +++ b/doc/source/reference/arrays.classes.rst @@ -330,6 +330,8 @@ NumPy provides several hooks that classes can customize: returned by :func:`__array__`. This practice will return ``TypeError``. +.. _matrix-objects: + Matrix objects ============== diff --git a/doc/source/reference/arrays.ndarray.rst b/doc/source/reference/arrays.ndarray.rst index 191367058..106ccd7cb 100644 --- a/doc/source/reference/arrays.ndarray.rst +++ b/doc/source/reference/arrays.ndarray.rst @@ -567,10 +567,10 @@ Matrix Multiplication: .. note:: Matrix operators ``@`` and ``@=`` were introduced in Python 3.5 - following PEP465. NumPy 1.10.0 has a preliminary implementation of ``@`` - for testing purposes. Further documentation can be found in the - :func:`matmul` documentation. + following PEP465_ and are available since NumPy 1.10.0. Further + information can be found in the :func:`matmul` documentation. +.. _PEP465: https://www.python.org/dev/peps/pep-0465/ Special methods =============== diff --git a/doc/source/reference/routines.linalg.rst b/doc/source/reference/routines.linalg.rst index 86e168b26..97bdf3974 100644 --- a/doc/source/reference/routines.linalg.rst +++ b/doc/source/reference/routines.linalg.rst @@ -30,10 +30,26 @@ flexible broadcasting options. For example, `numpy.linalg.solve` can handle "stacked" arrays, while `scipy.linalg.solve` accepts only a single square array as its first argument. +.. note:: + + The term *matrix* as it is used on this page indicates a 2d `numpy.array` + object, and *not* a `numpy.matrix` object. The latter is no longer + recommended, even for linear algebra. See + :ref:`the matrix object documentation<matrix-objects>` for + more information. + +The ``@`` operator +------------------ + +Introduced in NumPy 1.10.0, the ``@`` and ``@=`` operators are preferable to +other methods when computing the matrix product between 2d arrays. The +:func:`numpy.matmul` function implements the semantics of the ``@`` operator. + .. currentmodule:: numpy Matrix and vector products -------------------------- + .. autosummary:: :toctree: generated/ diff --git a/numpy/core/code_generators/ufunc_docstrings.py b/numpy/core/code_generators/ufunc_docstrings.py index 04181fbc2..fe3f88eb2 100644 --- a/numpy/core/code_generators/ufunc_docstrings.py +++ b/numpy/core/code_generators/ufunc_docstrings.py @@ -2808,7 +2808,7 @@ add_newdoc('numpy.core.umath', 'matmul', (9, 5, 7, 3) >>> # n is 7, k is 4, m is 3 - The matmul function implements the semantics of the `@` operator introduced + The matmul function implements the semantics of the ``@`` operator introduced in Python 3.5 following PEP465. Examples |