10000 MAINT: Address smaller review comments. · numpy/numpy@9ce67f6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ce67f6

Browse files
committed
MAINT: Address smaller review comments.
1 parent cdbea5e commit 9ce67f6

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

numpy/_core/include/numpy/_dtype_api.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,17 @@ typedef struct {
129129
* SLOTS IDs For the ArrayMethod creation, once fully public, IDs are fixed
130130
* but can be deprecated and arbitrarily extended.
131131
*/
132-
#define NPY_METH_resolve_descriptors_with_scalars 1
132+
#define _NPY_METH_resolve_descriptors_with_scalars 1
133133
#define NPY_METH_resolve_descriptors 2
134134
/* We may want to adapt the `get_loop` signature a bit: */
135-
#define _NPY_METH_get_loop 4
136-
#define NPY_METH_get_reduction_initial 5
135+
#define _NPY_METH_get_loop 3
136+
#define NPY_METH_get_reduction_initial 4
137137
/* specific loops for constructions/default get_loop: */
138-
#define NPY_METH_strided_loop 6
139-
#define NPY_METH_contiguous_loop 7
140-
#define NPY_METH_unaligned_strided_loop 8
141-
#define NPY_METH_unaligned_contiguous_loop 9
142-
#define NPY_METH_contiguous_indexed_loop 10
138+
#define NPY_METH_strided_loop 5
139+
#define NPY_METH_contiguous_loop 6
140+
#define NPY_METH_unaligned_strided_loop 7
141+
#define NPY_METH_unaligned_contiguous_loop 8
142+
#define NPY_METH_contiguous_indexed_loop 9
143143

144144
/*
145145
* The resolve descriptors function, must be able to handle NULL values for
@@ -166,6 +166,10 @@ typedef NPY_CASTING (resolve_descriptors_function)(
166166
/*
167167
* Rarely needed, slightly more powerful version of `resolve_descriptors`.
168168
* See also `resolve_descriptors_function` for details on shared arguments.
169+
*
170+
* NOTE: This function is private now as it is unclear how and what to pass
171+
* exactly as additional information to allow dealing with the scalars.
172+
* See also gh-24915.
169173
*/
170174
typedef NPY_CASTING (resolve_descriptors_with_scalars_function)(
171175
struct PyArrayMethodObject_tag *method,

numpy/_core/src/umath/special_integer_comparisons.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ init_special_int_comparisons(PyObject *umath)
423423
*/
424424
PyType_Slot slots[] = {
425425
{_NPY_METH_get_loop, nullptr},
426-
{NPY_METH_resolve_descriptors_with_scalars,
426+
{_NPY_METH_resolve_descriptors_with_scalars,
427427
(void *)&resolve_descriptors_with_scalars},
428428
{0, NULL},
429429
};

numpy/_core/src/umath/ufunc_object.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static PyObject *
115115
prepare_input_arguments_for_outer(PyObject *args, PyUFuncObject *ufunc);
116116

117117
static int
118-
resolve_descriptors(int nop, int nin,
118+
resolve_descriptors(int nop,
119119
PyUFuncObject *ufunc, PyArrayMethodObject *ufuncimpl,
120120
PyArrayObject *operands[], PyArray_Descr *dtypes[],
121121
PyArray_DTypeMeta *signature[], PyObject *inputs_tup,
@@ -2804,7 +2804,7 @@ reducelike_promote_and_resolve(PyUFuncObject *ufunc,
28042804
* casting safety could in principle be set to the default same-kind.
28052805
* (although this should possibly happen through a deprecation)
28062806
*/
2807-
if (resolve_descriptors(3, 2, ufunc, ufuncimpl,
2807+
if (resolve_descriptors(3, ufunc, ufuncimpl,
28082808
ops, out_descrs, signature, NULL, casting) < 0) {
28092809
return NULL;
28102810
}
@@ -4476,7 +4476,7 @@ _get_fixed_signature(PyUFuncObject *ufunc,
44764476
* need to "cast" to string first).
44774477
*/
44784478
static int
4479-
resolve_descriptors(int nop, int nin,
4479+
resolve_descriptors(int nop,
44804480
PyUFuncObject *ufunc, PyArrayMethodObject *ufuncimpl,
44814481
PyArrayObject *operands[], PyArray_Descr *dtypes[],
44824482
PyArray_DTypeMeta *signature[], PyObject *inputs_tup,
@@ -4495,6 +4495,7 @@ resolve_descriptors(int nop, int nin,
44954495
* 2. Can in principle customize `PyArray_CastDescrToDType()`
44964496
* (also because we want to avoid calling it for the scalars).
44974497
*/
4498+
int nin = ufunc->nin;
44984499
PyObject *input_scalars[NPY_MAXARGS];
44994500
for (int i = 0; i < nop; i++) {
45004501
if (operands[i] == NULL) {
@@ -4905,7 +4906,7 @@ ufunc_generic_fastcall(PyUFuncObject *ufunc,
49054906
}
49064907

49074908
/* Find the correct descriptors for the operation */
4908-
if (resolve_descriptors(nop, nin, ufunc, ufuncimpl,
4909+
if (resolve_descriptors(nop, ufunc, ufuncimpl,
49094910
operands, operation_descrs, signature, full_args.in, casting) < 0) {
49104911
goto fail;
49114912
}
@@ -6277,7 +6278,7 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)
62776278
}
62786279

62796280
/* Find the correct operation_descrs for the operation */
6280-
int resolve_result = resolve_descriptors(nop, ufunc->nin, ufunc, ufuncimpl,
6281+
int resolve_result = resolve_descriptors(nop, ufunc, ufuncimpl,
62816282
tmp_operands, operation_descrs, signature, NULL, NPY_UNSAFE_CASTING);
62826283
for (int i = 0; i < 3; i++) {
62836284
Py_XDECREF(signature[i]);
@@ -6606,7 +6607,7 @@ py_resolve_dtypes_generic(PyUFuncObject *ufunc, npy_bool return_context,
66066607
}
66076608

66086609
/* Find the correct descriptors for the operation */
6609-
if (resolve_descriptors(ufunc->nargs, ufunc->nin, ufunc, ufuncimpl,
6610+
if (resolve_descriptors(ufunc->nargs, ufunc, ufuncimpl,
66106611
dummy_arrays, operation_descrs, signature,
66116612
NULL, casting) < 0) {
66126613
goto finish;
< 32B9 /div>

0 commit comments

Comments
 (0)
0