8000 API,MAINT: Make ``NpyIter_GetTransferFlags`` public and avoid old uses by seberg · Pull Request #27998 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

API,MAINT: Make NpyIter_GetTransferFlags public and avoid old uses #27998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MAINT: Make needs_api declaration local in most cases as per review
  • Loading branch information
seberg committed Dec 17, 2024
commit 71e33fd4cd73d69fe173ed9790541758e2195d1d
3 changes: 1 addition & 2 deletions numpy/_core/src/multiarray/ctors.c
Original file line number Diff line number Diff line change
Expand Up @@ -2696,7 +2696,6 @@ PyArray_CopyAsFlat(PyArrayObject *dst, PyArrayObject *src, NPY_ORDER order)

npy_intp dst_count, src_count, count;
npy_intp dst_size, src_size;
int needs_api;

NPY_BEGIN_THREADS_DEF;

Expand Down Expand Up @@ -2787,7 +2786,7 @@ PyArray_CopyAsFlat(PyArrayObject *dst, PyArrayObject *src, NPY_ORDER order)
return -1;
}
/* No need to worry about API use in unbuffered iterator */
needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
int needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
if (!(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
npy_clear_floatstatus_barrier((char *)src_iter);
}
Expand Down
3 changes: 1 addition & 2 deletions numpy/_core/src/multiarray/einsum.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,6 @@ PyArray_EinsteinSum(char *subscripts, npy_intp nop,
char **dataptr;
npy_intp *stride;
npy_intp *countptr;
int needs_api;
NPY_BEGIN_THREADS_DEF;

iternext = NpyIter_GetIterNext(iter, NULL);
Expand All @@ -1139,7 +1138,7 @@ PyArray_EinsteinSum(char *subscripts, npy_intp nop,
stride = NpyIter_GetInnerStrideArray(iter);
countptr = NpyIter_GetInnerLoopSizePtr(iter);
/* IterationNeedsAPI additionally checks for object dtype here. */
needs_api = NpyIter_IterationNeedsAPI(iter);
int needs_api = NpyIter_IterationNeedsAPI(iter);
if (!needs_api) {
NPY_BEGIN_THREADS_THRESHOLDED(NpyIter_GetIterSize(iter));
}
Expand Down
11 changes: 5 additions & 6 deletions numpy/_core/src/umath/ufunc_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,6 @@ PyUFunc_GeneralizedFunctionInternal(PyUFuncObject *ufunc,
int i, j, idim, nop;
const char *ufunc_name;
int retval;
int needs_api = 0;

/* Use remapped axes for generalized ufunc */
int broadcast_ndim, iter_ndim;
Expand Down Expand Up @@ -2093,7 +2092,7 @@ PyUFunc_GeneralizedFunctionInternal(PyUFuncObject *ufunc,
goto fail;
}
flags = PyArrayMethod_COMBINED_FLAGS(flags, NpyIter_GetTransferFlags(iter));
needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
int needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;

if (!(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
/* Start with the floating-point exception flags cleared */
Expand Down Expand Up @@ -2575,7 +2574,7 @@ PyUFunc_Accumulate(PyUFuncObject *ufunc, PyArrayObject *arr, PyArrayObject *out,
int *op_axes[2] = {op_axes_arrays[0], op_axes_arrays[1]};
npy_uint32 op_flags[2];
int idim, ndim;
int needs_api, need_outer_iterator;
int need_outer_iterator;
int res = 0;

NPY_cast_info copy_info;
Expand Down Expand Up @@ -2762,7 +2761,7 @@ PyUFunc_Accumulate(PyUFuncObject *ufunc, PyArrayObject *arr, PyArrayObject *out,
flags = PyArrayMethod_COMBINED_FLAGS(flags, NpyIter_GetTransferFlags(iter));
}

needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
int needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
if (!(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
/* Start with the floating-point exception flags cleared */
npy_clear_floatstatus_barrier((char*)&iter);
Expand Down Expand Up @@ -2983,7 +2982,7 @@ PyUFunc_Reduceat(PyUFuncObject *ufunc, PyArrayObject *arr, PyArrayObject *ind,
op_axes_arrays[2]};
npy_uint32 op_flags[3];
int idim, ndim;
int needs_api, need_outer_iterator = 0;
int need_outer_iterator = 0;

int res = 0;

Expand Down Expand Up @@ -3186,7 +3185,7 @@ PyUFunc_Reduceat(PyUFuncObject *ufunc, PyArrayObject *arr, PyArrayObject *ind,
flags = PyArrayMethod_COMBINED_FLAGS(flags, NpyIter_GetTransferFlags(iter));
}

needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
int needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
if (!(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
/* Start with the floating-point exception flags cleared */
npy_clear_floatstatus_barrier((char*)&iter);
Expand Down
Loading
0