10000 BUG: Removes ValueError for empty kwargs in arraymultiter_new · numpy/numpy@1bd5d34 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1bd5d34

Browse files
hdamron17charris
authored andcommitted
BUG: Removes ValueError for empty kwargs in arraymultiter_new
closes gh-13455
1 parent 1b5b0b4 commit 1bd5d34

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

numpy/core/src/multiarray/iterators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ arraymultiter_new(PyTypeObject *NPY_UNUSED(subtype), PyObject *args, PyObject *k
13871387
PyArrayMultiIterObject *multi;
13881388
PyObject *arr;
13891389

1390-
if (kwds != NULL) {
1390+
if (kwds != NULL && PyDict_Size(kwds) > 0) {
13911391
PyErr_SetString(PyExc_ValueError,
13921392
"keyword arguments not accepted.");
13931393
return NULL;

numpy/core/tests/test_numeric.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2726,6 +2726,18 @@ def test_number_of_arguments(self):
27262726
mit = np.broadcast(*arrs)
27272727
assert_equal(mit.numiter, j)
27282728

2729+
def test_broadcast_error_kwargs(self):
2730+
#gh-13455
2731+
arrs = [np.empty((5, 6, 7))]
2732+
mit = np.broadcast(*arrs)
2733+
mit2 = np.broadcast(*arrs, **{})
2734+
assert_equal(mit.shape, mit2.shape)
2735+
assert_equal(mit.ndim, mit2.ndim)
2736+
assert_equal(mit.nd, mit2.nd)
2737+
assert_equal(mit.numiter, mit2.numiter)
2738+
assert_(mit.iters[0].base is mit2.iters[0].base)
2739+
2740+
assert_raises(ValueError, np.broadcast, 1, **{'x': 1})
27292741

27302742
class TestKeepdims(object):
27312743

0 commit comments

Comments
 (0)
0