From 6d5283a811f5f727bc7486e596d8048f5315a6d2 Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Thu, 2 Oct 2008 20:27:17 +0000 Subject: Fix problem with subclasses of object arrays. --- numpy/core/src/ufuncobject.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'numpy/core/src/ufuncobject.c') diff --git a/numpy/core/src/ufuncobject.c b/numpy/core/src/ufuncobject.c index fd14936a8..ab4ecef75 100644 --- a/numpy/core/src/ufuncobject.c +++ b/numpy/core/src/ufuncobject.c @@ -1427,12 +1427,15 @@ construct_arrays(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps, * FAIL with NotImplemented if the other object has * the __r__ method and has __array_priority__ as * an attribute (signalling it can handle ndarray's) - * and is not already an ndarray + * and is not already an ndarray or a subtype of the same type. */ if ((arg_types[1] == PyArray_OBJECT) && \ (loop->ufunc->nin==2) && (loop->ufunc->nout == 1)) { PyObject *_obj = PyTuple_GET_ITEM(args, 1); - if (!PyArray_CheckExact(_obj) && \ + if (!PyArray_CheckExact(_obj) && + /* If both are same subtype of object arrays, then proceed */ + !(_obj->ob_type == (PyTuple_GET_ITEM(args, 0))->ob_type) && \ + PyObject_HasAttrString(_obj, "__array_priority__") && \ _has_reflected_op(_obj, loop->ufunc->name)) { loop->notimplemented = 1; -- cgit v1.2.1