diff options
author | Nathaniel J. Smith <njs@pobox.com> | 2015-05-07 20:37:29 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2015-06-13 12:32:54 -0600 |
commit | a0643f542642537cb4f4b3fa057fbbecaf799b29 (patch) | |
tree | d8775c422c7c4bcbf7be1573cbab3f4bb5a8dabb /numpy/lib/utils.py | |
parent | 1e3ab40493fadb5daa67c8a55c5360fd934cca7b (diff) | |
download | numpy-a0643f542642537cb4f4b3fa057fbbecaf799b29.tar.gz |
MAINT: add __array_priority__ special case to masked array binary ops
ndarray special methods like __add__ have a special case where if the
right argument is not an ndarray or subclass, and it has higher
__array_priority__ than the left argument, then we return
NotImplemented and let the right argument handle the operation.
ufuncs have traditionally had a similar but different special case,
where if it's a 2 input - 1 output ufunc, and the right argument is
not an ndarray (exactly, subclasses don't count), and when converted
to an ndarray ends up as an object array (presumably b/c it doesn't
have a meaningful coercion route, though who knows), and it has a
higher __array_priority__ than the left argument AND it has a
__r<operation>__ attribute, then they return NotImplemented.
In practice this latter special case is not used by regular ndarrays,
b/c anytime it would need to be triggered, the former special case
triggers first and the ufunc is never called. However, numpy.ma did
not have the former special case, and was thus relying on the ufunc
special case. This commit adds the special case to the numpy.ma
special methods directly, so that they no longer depend on the quirky
ufunc behaviour.
It also cleans up the relevant test to things that actually should be
true in general, instead of just testing some implementation details.
Diffstat (limited to 'numpy/lib/utils.py')
0 files changed, 0 insertions, 0 deletions