Skip to content

Commit

Permalink
MAINT: Remove unused delegate_binop code
Browse files Browse the repository at this point in the history
This is handled in the C code now within the ufunc machinery.
  • Loading branch information
greglucas committed Jan 3, 2023
1 parent e6e80e6 commit 366dfc3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
6 changes: 0 additions & 6 deletions numpy/core/src/common/binop_override.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,6 @@ binop_should_defer(PyObject *self, PyObject *other, int inplace)
* logic for forward binop implementations.
*/

/*
* NB: there's another copy of this code in
* numpy.ma.core.MaskedArray._delegate_binop
* which should possibly be updated when this is.
*/

PyObject *attr;
double self_prio, other_prio;
int defer;
Expand Down
17 changes: 2 additions & 15 deletions numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3163,7 +3163,8 @@ def __array_ufunc__(self, np_ufunc, method, *inputs, **kwargs):
# Determine what class types we are compatible with and return
# NotImplemented if we don't know how to handle them
for arg in args:
if not isinstance(arg, ndarray) and hasattr(arg, "__array_ufunc__"):
if (not isinstance(arg, ndarray)
and hasattr(arg, "__array_ufunc__")):
# we want to defer to other implementations, unless it is an
# ndarray which MaskedArray will handle here instead
return NotImplemented
Expand Down Expand Up @@ -4181,20 +4182,6 @@ def __repr__(self):
)
return prefix + result + ')'

def _delegate_binop(self, other):
# This emulates the logic in
# private/binop_override.h:forward_binop_should_defer
if isinstance(other, type(self)):
return False
array_ufunc = getattr(other, "__array_ufunc__", False)
if array_ufunc is False:
other_priority = getattr(other, "__array_priority__", -1000000)
return self.__array_priority__ < other_priority
else:
# If array_ufunc is not None, it will be called inside the ufunc;
# None explicitly tells us to not call the ufunc, i.e., defer.
return array_ufunc is None

def _comparison(self, other, compare):
"""Compare self with other using operator.eq or operator.ne.
Expand Down

0 comments on commit 366dfc3

Please sign in to comment.