diff options
author | Pauli Virtanen <pav@iki.fi> | 2014-07-24 23:58:28 +0300 |
---|---|---|
committer | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2015-04-04 21:47:01 -0400 |
commit | 367b4094125062fa9018db0f310b28780259f29b (patch) | |
tree | 33062684a21778b95ff949295aee291ee20e7322 /numpy/core/defchararray.py | |
parent | 4679ff2380c01f18ea8cfd2d89838ba53f6381de (diff) | |
download | numpy-367b4094125062fa9018db0f310b28780259f29b.tar.gz |
BUG: core: ensure binop execution uses ufuncs as fallback
These changes only affect objects defining __numpy_ufunc__. Other
objects use the __array_priority__ mechanism to decide whether
NotImplemented should be returned or not.
The binops previously returned NotImplemented even if other._r<op>__ is
ndarray.__r<op>__, rather than trying to evaluate the result via ufuncs.
This causes problems in binops of two objects that both subclass from
ndarray and define __numpy_ufunc__.
The solution added here makes the total logic as follows:
def __binop__(self, other):
if (hasattr(other, '__numpy_ufunc__') and
not isinstance(other, self.__class__) and
hasattr(other, '__rop__') and
other.__class__.__rop__ is not self.__class__.__rop__):
return NotImplemented
return np.binop(self, other)
Diffstat (limited to 'numpy/core/defchararray.py')
0 files changed, 0 insertions, 0 deletions