diff options
author | Stephan Hoyer <shoyer@google.com> | 2017-05-05 21:50:18 -0700 |
---|---|---|
committer | Stephan Hoyer <shoyer@google.com> | 2017-05-07 17:03:40 -0700 |
commit | d51b538ba80d36841cc57911d77ea61cd1d3fb25 (patch) | |
tree | 0c8cbc64c3ae6eb4dd0bda4a810d64902b974324 /numpy/lib/mixins.py | |
parent | c9d1f9e467155cec3030b0970816abe928244b9c (diff) | |
download | numpy-d51b538ba80d36841cc57911d77ea61cd1d3fb25.tar.gz |
ENH: add divmod support to NDArrayOperatorsMixin
Diffstat (limited to 'numpy/lib/mixins.py')
-rw-r--r-- | numpy/lib/mixins.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/numpy/lib/mixins.py b/numpy/lib/mixins.py index bbeed1437..fbdc2edfb 100644 --- a/numpy/lib/mixins.py +++ b/numpy/lib/mixins.py @@ -70,8 +70,7 @@ class NDArrayOperatorsMixin(object): implement. This class does not yet implement the special operators corresponding - to ``divmod`` or ``matmul`` (``@``), because these operation do not yet - have corresponding NumPy ufuncs. + 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 @@ -161,7 +160,10 @@ class NDArrayOperatorsMixin(object): um.true_divide, 'truediv') __floordiv__, __rfloordiv__, __ifloordiv__ = _numeric_methods( um.floor_divide, 'floordiv') - __mod__, __rmod__, __imod__ = _numeric_methods(um.mod, 'mod') + __mod__, __rmod__, __imod__ = _numeric_methods(um.remainder, 'mod') + __divmod__ = _binary_method(um.divmod, 'divmod') + __rdivmod__ = _reflected_binary_method(um.divmod, 'divmod') + # __idivmod__ does not exist # TODO: handle the optional third argument for __pow__? __pow__, __rpow__, __ipow__ = _numeric_methods(um.power, 'pow') __lshift__, __rlshift__, __ilshift__ = _numeric_methods( |