Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 01a251b

Browse filesBrowse files
committed
MAINT: Use has_ref for trivial copy decision and remove unused needs_api
The dtype is forced to be the same, swapping is impossible but even if it was possible, it wouldn't matter here.
1 parent 2db272b commit 01a251b
Copy full SHA for 01a251b

File tree

Expand file treeCollapse file tree

1 file changed

+7
-12
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-12
lines changed

‎numpy/core/src/multiarray/multiarraymodule.c

Copy file name to clipboardExpand all lines: numpy/core/src/multiarray/multiarraymodule.c
+7-12Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3409,7 +3409,6 @@ PyArray_Where(PyObject *condition, PyObject *x, PyObject *y)
34093409
PyArray_Descr * op_dt[4] = {common_dt, PyArray_DescrFromType(NPY_BOOL),
34103410
common_dt, common_dt};
34113411
NpyIter * iter;
3412-
int needs_api;
34133412
NPY_BEGIN_THREADS_DEF;
34143413

34153414
if (common_dt == NULL || op_dt[1] == NULL) {
@@ -3426,23 +3425,19 @@ PyArray_Where(PyObject *condition, PyObject *x, PyObject *y)
34263425
goto fail;
34273426
}
34283427

3429-
needs_api = NpyIter_IterationNeedsAPI(iter);
3430-
34313428
/* Get the result from the iterator object array */
34323429
ret = (PyObject*)NpyIter_GetOperandArray(iter)[0];
34333430

34343431
npy_intp itemsize = common_dt->elsize;
34353432

3436-
int swap = PyDataType_ISBYTESWAPPED(common_dt);
3437-
int native = (swap == 0) && !needs_api;
3433+
int has_ref = PyDataType_REFCHK(common_dt);
34383434

34393435
NPY_ARRAYMETHOD_FLAGS transfer_flags = 0;
34403436

34413437
npy_intp transfer_strides[2] = {itemsize, itemsize};
3442-
34433438
npy_intp one = 1;
34443439

3445-
if (!native || ((itemsize != 16) && (itemsize != 8) && (itemsize != 4) &&
3440+
if (has_ref || ((itemsize != 16) && (itemsize != 8) && (itemsize != 4) &&
34463441
(itemsize != 2) && (itemsize != 1))) {
34473442
// The iterator has NPY_ITER_ALIGNED flag so no need to check alignment
34483443
// of the input arrays.
@@ -3483,19 +3478,19 @@ PyArray_Where(PyObject *condition, PyObject *x, PyObject *y)
34833478
npy_intp ystride = strides[3];
34843479

34853480
/* constant sizes so compiler replaces memcpy */
3486-
if (native && itemsize == 16) {
3481+
if (!has_ref && itemsize == 16) {
34873482
INNER_WHERE_LOOP(16);
34883483
}
3489-
else if (native && itemsize == 8) {
3484+
else if (!has_ref && itemsize == 8) {
34903485
INNER_WHERE_LOOP(8);
34913486
}
3492-
else if (native && itemsize == 4) {
3487+
else if (!has_ref && itemsize == 4) {
34933488
INNER_WHERE_LOOP(4);
34943489
}
3495-
else if (native && itemsize == 2) {
3490+
else if (!has_ref && itemsize == 2) {
34963491
INNER_WHERE_LOOP(2);
34973492
}
3498-
else if (native && itemsize == 1) {
3493+
else if (!has_ref && itemsize == 1) {
34993494
INNER_WHERE_LOOP(1);
35003495
}
35013496
else {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.