summaryrefslogtreecommitdiff
path: root/numpy/lib/mixins.py
diff options
context:
space:
mode:
authorStephan Hoyer <shoyer@gmail.com>2018-12-05 10:01:47 -0800
committerGitHub <noreply@github.com>2018-12-05 10:01:47 -0800
commit8a115731966db1d723d03b4b599a5f3587edc94b (patch)
tree71fcbd23988350d8b07ffb3607152a1fb7be4e69 /numpy/lib/mixins.py
parent9d416356baf4a653b2c647a921ae24ba7d39e8df (diff)
downloadnumpy-8a115731966db1d723d03b4b599a5f3587edc94b.tar.gz
ENH: implement matmul on NDArrayOperatorsMixin (#12488)
* ENH: implement matmul on NDArrayOperatorsMixin * MAINT: remove unnecessary pytest import
Diffstat (limited to 'numpy/lib/mixins.py')
-rw-r--r--numpy/lib/mixins.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/numpy/lib/mixins.py b/numpy/lib/mixins.py
index 0379ecb1a..52ad45b68 100644
--- a/numpy/lib/mixins.py
+++ b/numpy/lib/mixins.py
@@ -69,9 +69,6 @@ class NDArrayOperatorsMixin(object):
deferring to the ``__array_ufunc__`` method, which subclasses must
implement.
- This class does not yet implement the special operators corresponding
- to ``matmul`` (``@``), because ``np.matmul`` is not yet a NumPy ufunc.
-
It is useful for writing classes that do not inherit from `numpy.ndarray`,
but that should support arithmetic and numpy universal functions like
arrays as described in `A Mechanism for Overriding Ufuncs
@@ -155,6 +152,8 @@ class NDArrayOperatorsMixin(object):
__add__, __radd__, __iadd__ = _numeric_methods(um.add, 'add')
__sub__, __rsub__, __isub__ = _numeric_methods(um.subtract, 'sub')
__mul__, __rmul__, __imul__ = _numeric_methods(um.multiply, 'mul')
+ __matmul__, __rmatmul__, __imatmul__ = _numeric_methods(
+ um.matmul, 'matmul')
if sys.version_info.major < 3:
# Python 3 uses only __truediv__ and __floordiv__
__div__, __rdiv__, __idiv__ = _numeric_methods(um.divide, 'div')