summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/umath/ufunc_object.c2
-rw-r--r--numpy/core/tests/test_ufunc.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c
index 500c72620..6cf5fbbba 100644
--- a/numpy/core/src/umath/ufunc_object.c
+++ b/numpy/core/src/umath/ufunc_object.c
@@ -4085,7 +4085,7 @@ PyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args,
}
/* Otherwise return the array unscathed */
else {
- return (PyObject *)mp;
+ return PyArray_Return(mp);
}
}
PyErr_Format(PyExc_TypeError, "cannot %s on a scalar",
diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py
index 69f2b3c74..be7dae8eb 100644
--- a/numpy/core/tests/test_ufunc.py
+++ b/numpy/core/tests/test_ufunc.py
@@ -515,6 +515,12 @@ class TestUfunc(TestCase):
assert_equal(np.max(3, axis=0), 3)
assert_equal(np.min(2.5, axis=0), 2.5)
+ # Make sure that scalars are coming out from this operation
+ assert_(type(np.prod(np.float32(2.5), axis=0)) is np.float32)
+ assert_(type(np.sum(np.float32(2.5), axis=0)) is np.float32)
+ assert_(type(np.max(np.float32(2.5), axis=0)) is np.float32)
+ assert_(type(np.min(np.float32(2.5), axis=0)) is np.float32)
+
def test_casting_out_param(self):
# Test that it's possible to do casts on output
a = np.ones((200,100), np.int64)