Skip to content

Commit

Permalink
Merge pull request numpy#3102 from seberg/nditer-fix-op_axes-initiali…
Browse files Browse the repository at this point in the history
…zation

BUG: initialize op_axes when only itershape is given
  • Loading branch information
charris committed Mar 1, 2013
2 parents d111fbd + e12dc1c commit 890ee94
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/nditer_pywrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ npyiter_init(NewNpyArrayIterObject *self, PyObject *args, PyObject *kwds)
if (itershape.len > 0) {
if (oa_ndim == 0) {
oa_ndim = itershape.len;
memset(op_axes, 0, sizeof(op_axes[0])*oa_ndim);
memset(op_axes, 0, sizeof(op_axes[0]) * nop);
}
else if (oa_ndim != itershape.len) {
PyErr_SetString(PyExc_ValueError,
Expand Down
2 changes: 2 additions & 0 deletions numpy/core/tests/test_nditer.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,8 @@ def test_iter_itershape():
[['readonly'], ['writeonly','allocate']],
op_axes=[[0,1,None], None],
itershape=(-1,1,4))
# Test bug that for no op_axes but itershape, they are NULLed correctly
i = np.nditer([np.ones(2), None, None], itershape=(2,))

def test_iter_broadcasting_errors():
# Check that errors are thrown for bad broadcasting shapes
Expand Down

0 comments on commit 890ee94

Please sign in to comment.