Skip to content

Commit

Permalink
Merge pull request numpy#13508 from hdamron17/arraymultiter_new-empty…
Browse files Browse the repository at this point in the history
…-kwds

BUG: Removes ValueError for empty kwargs in arraymultiter_new
  • Loading branch information
charris authored May 11, 2019
2 parents 634d66d + c9407cc commit 7db299e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/iterators.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ arraymultiter_new(PyTypeObject *NPY_UNUSED(subtype), PyObject *args, PyObject *k
PyArrayMultiIterObject *multi;
PyObject *arr;

if (kwds != NULL) {
if (kwds != NULL && PyDict_Size(kwds) > 0) {
PyErr_SetString(PyExc_ValueError,
"keyword arguments not accepted.");
return NULL;
Expand Down
12 changes: 12 additions & 0 deletions numpy/core/tests/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -2766,6 +2766,18 @@ def test_number_of_arguments(self):
mit = np.broadcast(*arrs)
assert_equal(mit.numiter, j)

def test_broadcast_error_kwargs(self):
#gh-13455
arrs = [np.empty((5, 6, 7))]
mit = np.broadcast(*arrs)
mit2 = np.broadcast(*arrs, **{})
assert_equal(mit.shape, mit2.shape)
assert_equal(mit.ndim, mit2.ndim)
assert_equal(mit.nd, mit2.nd)
assert_equal(mit.numiter, mit2.numiter)
assert_(mit.iters[0].base is mit2.iters[0].base)

assert_raises(ValueError, np.broadcast, 1, **{'x': 1})

class TestKeepdims(object):

Expand Down

0 comments on commit 7db299e

Please sign in to comment.