summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/ufuncobject.c3
-rw-r--r--numpy/core/tests/test_umath.py25
2 files changed, 27 insertions, 1 deletions
diff --git a/numpy/core/src/ufuncobject.c b/numpy/core/src/ufuncobject.c
index b15639333..b903b6646 100644
--- a/numpy/core/src/ufuncobject.c
+++ b/numpy/core/src/ufuncobject.c
@@ -2517,7 +2517,7 @@ _find_array_wrap(PyObject *args)
int np = 0;
int argmax = 0;
double priority[MAX_ARGS];
- double maxpriority = PyArray_SUBTYPE_PRIORITY;
+ double maxpriority;
PyObject *with_wrap[MAX_ARGS];
PyObject *attr, *wrap;
PyObject *obj;
@@ -2553,6 +2553,7 @@ _find_array_wrap(PyObject *args)
if (np == 0) return NULL;
wrap = with_wrap[0];
+ maxpriority = priority[0];
for (i=1; i<np; i++) {
if (priority[i] > maxpriority) {
maxpriority = priority[i];
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index 4d9f45347..aea720fa1 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -61,5 +61,30 @@ class test_special_methods(ScipyTestCase):
x = minimum(a, a)
assert_equal(x.arr, zeros(1))
+ def test_priority(self):
+ class A(object):
+ def __array__(self):
+ return zeros(1)
+ def __array_wrap__(self, arr, context):
+ r = type(self)()
+ r.arr = arr
+ r.context = context
+ return r
+ class B(A):
+ __array_priority__ = 20
+ class C(A):
+ __array_priority__ = 40
+ a = A()
+ b = B()
+ c = C()
+ f = minimum
+ self.failUnless(isinstance(f(a,a), A))
+ self.failUnless(isinstance(f(a,b), B))
+ self.failUnless(isinstance(f(b,a), B))
+ self.failUnless(isinstance(f(b,b), B))
+ self.failUnless(isinstance(f(b,c), C))
+ self.failUnless(isinstance(f(c,b), C))
+ self.failUnless(isinstance(f(c,c), C))
+
if __name__ == "__main__":
ScipyTest().run()