Skip to content

Commit c89f955

Browse files
committed
BUG: fix incorrect output descriptor in fancy indexing
1 parent fbffb8c commit c89f955

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

numpy/_core/src/multiarray/mapping.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,7 @@ array_subscript(PyArrayObject *self, PyObject *op)
16681668

16691669
if (PyArray_GetDTypeTransferFunction(1,
16701670
itemsize, itemsize,
1671-
PyArray_DESCR(self), PyArray_DESCR(self),
1671+
PyArray_DESCR(self), PyArray_DESCR(mit->extra_op),
16721672
0, &cast_info, &transfer_flags) != NPY_SUCCEED) {
16731673
goto finish;
16741674
}

numpy/_core/tests/test_stringdtype.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,14 +496,15 @@ def test_fancy_indexing(string_list):
496496
assert_array_equal(sarr, sarr[np.arange(sarr.shape[0])])
497497

498498
# see gh-27003 and gh-27053
499-
for ind in [[True, True], [0, 1], ...]:
500-
for lop in [['a'*16, 'b'*16], ['', '']]:
499+
for ind in [[True, True], [0, 1], ..., np.array([0, 1], dtype='uint8')]:
500+
for lop in [['a'*25, 'b'*25], ['', '']]:
501501
a = np.array(lop, dtype="T")
502-
rop = ['d'*16, 'e'*16]
502+
assert_array_equal(a[ind], a)
503+
rop = ['d'*25, 'e'*25]
503504
for b in [rop, np.array(rop, dtype="T")]:
504505
a[ind] = b
505506
assert_array_equal(a, b)
506-
assert a[0] == 'd'*16
507+
assert a[0] == 'd'*25
507508

508509

509510
def test_creation_functions():

0 commit comments

Comments
 (0)