diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2015-03-13 01:17:09 -0400 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2015-03-13 01:17:09 -0400 |
commit | 13032bb7008e10a90b84f1ef29b3d99a00e0a2e4 (patch) | |
tree | f728f9bff215ec4856f7d75ed6a9e4d38ffd57d2 | |
parent | ce7461eecea4b1952353c9f5459e51447206c5fc (diff) | |
parent | 6ac5172a6ee1ee65856086dc0556c81909248ab9 (diff) | |
download | numpy-13032bb7008e10a90b84f1ef29b3d99a00e0a2e4.tar.gz |
Merge pull request #5676 from jaimefrio/ufunc_at_nout
BUG: ufunc.at only works on single output ufuncs
-rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 6 | ||||
-rw-r--r-- | numpy/core/tests/test_ufunc.py | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index 9f2a7d57f..36201b3ea 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -5109,6 +5109,12 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args) return NULL; } + if (ufunc->nout != 1) { + PyErr_SetString(PyExc_ValueError, + "Only single output ufuncs supported at this time"); + return NULL; + } + if (!PyArg_ParseTuple(args, "OO|O", &op1, &idx, &op2)) { return NULL; } diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py index ab885bbf0..b3c281e2a 100644 --- a/numpy/core/tests/test_ufunc.py +++ b/numpy/core/tests/test_ufunc.py @@ -1095,6 +1095,9 @@ class TestUfunc(TestCase): self.assertRaises(TypeError, np.add.at, values, [0, 1], 1) assert_array_equal(values, np.array(['a', 1], dtype=np.object)) + # Test multiple output ufuncs raise error, gh-5665 + assert_raises(ValueError, np.modf.at, np.arange(10), [1]) + def test_reduce_arguments(self): f = np.add.reduce d = np.ones((5,2), dtype=int) |