10000 MAINT: Use direct subarray access to avoid warnings · numpy/numpy@ae8cd99 · GitHub
[go: up one dir, main page]

Skip to content

Commit ae8cd99

Browse files
committed
MAINT: Use direct subarray access to avoid warnings
1 parent 237524d commit ae8cd99

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

numpy/_core/src/multiarray/arraytypes.c.src

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ VOID_setitem(PyObject *op, void *input, void *vap)
11251125
}
11261126
return 0;
11271127
}
1128-
else if (PyDataType_HASSUBARRAY(descr)) {
1128+
else if (descr->subarray != NULL) {
11291129
/* copy into an array of the same basic type */
11301130
PyArray_Dims shape = {NULL, -1};
11311131
if (!(PyArray_IntpConverter(descr->subarray->shape, &shape))) {
@@ -2297,7 +2297,7 @@ VOID_copyswapn (char *dst, npy_intp dstride, char *src, npy_intp sstride,
22972297
}
22982298
return;
22992299
}
2300-
if (PyDataType_HASSUBARRAY(descr)) {
2300+
if (descr->subarray) {
23012301
PyArray_Descr *new;
23022302
npy_intp num;
23032303
npy_intp i;
@@ -2382,7 +2382,7 @@ VOID_copyswap (char *dst, char *src, int swap, PyArrayObject *arr)
23822382
}
23832383
return;
23842384
}
2385-
if (PyDataType_HASSUBARRAY(descr)) {
2385+
if (descr->subarray != NULL) {
23862386
PyArray_Descr *new;
23872387
npy_intp num;
23882388
int subitemsize;

numpy/_core/src/multiarray/descriptor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3043,7 +3043,7 @@ arraydescr_setstate(_PyArray_LegacyDescr *self, PyObject *args)
30433043
}
30443044

30453045
self->subarray = PyArray_malloc(sizeof(PyArray_ArrayDescr));
3046-
if (!PyDataType_HASSUBARRAY(self)) {
3046+
if (self->subarray == NULL) {
30473047
return PyErr_NoMemory();
30483048
}
30493049
self->subarray->base = (PyArray_Descr *)PyTuple_GET_ITEM(subarray, 0);
@@ -3341,7 +3341,7 @@ PyArray_DescrNewByteorder(PyArray_Descr *oself, char newendian)
33413341
Py_DECREF(new->fields);
33423342
new->fields = newfields;
33433343
}
3344-
if (PyDataType_HASSUBARRAY(new)) {
3344+
if (new->subarray) {
33453345
Py_DECREF(new->subarray->base);
33463346
new->subarray->base = PyArray_DescrNewByteorder(
33473347
self->subarray->base, newendian);

numpy/_core/src/multiarray/dtype_traversal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ npy_get_clear_void_and_legacy_user_dtype_loop(
516516
return 0;
517517
}
518518

519-
if (PyDataType_HASSUBARRAY(dtype)) {
519+
if (dtype->subarray != NULL) {
520520
PyArray_Dims shape = {NULL, -1};
521521
npy_intp size;
522522

@@ -602,7 +602,7 @@ npy_get_zerofill_void_and_legacy_user_dtype_loop(
602602
npy_intp stride, PyArrayMethod_TraverseLoop **out_func,
603603
NpyAuxData **out_auxdata, NPY_ARRAYMETHOD_FLAGS *flags)
604604
{
605-
if (PyDataType_HASSUBARRAY(dtype)) {
605+
if (dtype->subarray != NULL) {
606606
PyArray_Dims shape = {NULL, -1};
6 9040 07607
npy_intp size;
608608

numpy/_core/src/multiarray/hashdescr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ static int _array_descr_walk(PyArray_Descr* descr, PyObject *l)
244244
return -1;
245245
}
246246
}
247-
if(PyDataType_HASSUBARRAY(ldescr)) {
247+
if(ldescr->subarray != NULL) {
248248
st = _array_descr_walk_subarray(ldescr->subarray, l);
249249
if (st) {
250250
return -1;

0 commit comments

Comments
 (0)
0