Skip to content

Commit 41977b2

Browse files
authored
Merge pull request numpy#19600 from seberg/issue-19589
BUG: Fix bad write in masked iterator output copy paths
2 parents f25905b + 1579ca9 commit 41977b2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

numpy/core/src/multiarray/lowlevel_strided_loops.c.src

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ PyArray_TransferMaskedStridedToNDim(npy_intp ndim,
13161316
args, &count, strides, mask, mask_stride, cast_info->auxdata);
13171317
}
13181318
int res = stransfer(&cast_info->context,
1319-
args, &count, strides, mask, mask_stride, cast_info->auxdata);
1319+
args, &N, strides, mask, mask_stride, cast_info->auxdata);
13201320
if (res < 0) {
13211321
return -1;
13221322
}

numpy/core/tests/test_nditer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2738,7 +2738,12 @@ def _is_buffered(iterator):
27382738
@pytest.mark.parametrize("a",
27392739
[np.zeros((3,), dtype='f8'),
27402740
np.zeros((9876, 3*5), dtype='f8')[::2, :],
2741-
np.zeros((4, 312, 124, 3), dtype='f8')[::2, :, ::2, :]])
2741+
np.zeros((4, 312, 124, 3), dtype='f8')[::2, :, ::2, :],
2742+
# Also test with the last dimension strided (so it does not fit if
2743+
# there is repeated access)
2744+
np.zeros((9,), dtype='f8')[::3],
2745+
np.zeros((9876, 3*10), dtype='f8')[::2, ::5],
2746+
np.zeros((4, 312, 124, 3), dtype='f8')[::2, :, ::2, ::-1]])
27422747
def test_iter_writemasked(a):
27432748
# Note, the slicing above is to ensure that nditer cannot combine multiple
27442749
# axes into one. The repetition is just to make things a bit more

0 commit comments

Comments
 (0)