Skip to content

Commit f40d318

Browse files
committed
ENH: use n_ops struct for comparison
1 parent 265bedc commit f40d318

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

numpy/_core/src/umath/ufunc_object.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#include "mapping.h"
6666
#include "npy_static_data.h"
6767
#include "multiarraymodule.h"
68+
#include "../multiarray/number.h"
6869

6970
/********** PRINTF DEBUG TRACING **************/
7071
#define NPY_UF_DBG_TRACING 0
@@ -90,8 +91,6 @@ typedef struct {
9091

9192

9293
/* ---------------------------------------------------------------- */
93-
extern PyUFuncObject *UFUNC_MAXIMUM;
94-
extern PyUFuncObject *UFUNC_MINIMUM;
9594

9695
static PyObject *
9796
prepare_input_arguments_for_outer(PyObject *args, PyUFuncObject *ufunc);
@@ -4373,7 +4372,7 @@ ufunc_generic_fastcall(PyUFuncObject *ufunc,
43734372

43744373
/* Extra positional args but no keywords */
43754374
/* DEPRECATED NumPy 2.4, 2025-08 */
4376-
if (ufunc == UFUNC_MAXIMUM || ufunc == UFUNC_MINIMUM) {
4375+
if ((PyObject *)ufunc == n_ops.maximum || (PyObject *)ufunc == n_ops.minimum) {
43774376

43784377
if (DEPRECATE(
43794378
"Passing more than 2 positional arguments to np.maximum and np.minimum "

numpy/_core/src/umath/umathmodule.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040

4141

4242
static PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};
43-
PyUFuncObject *UFUNC_MAXIMUM = NULL;
44-
PyUFuncObject *UFUNC_MINIMUM = NULL;
4543

4644
static int
4745
object_ufunc_type_resolver(PyUFuncObject *ufunc,
@@ -284,17 +282,6 @@ int initumath(PyObject *m)
284282
PyDict_SetItemString(d, "conj", s);
285283
PyDict_SetItemString(d, "mod", s2);
286284

287-
PyObject *tmp;
288-
if (PyDict_GetItemStringRef(d, "maximum", &tmp) < 0) {
289-
return -1;
290-
}
291-
UFUNC_MAXIMUM = (PyUFuncObject *)tmp;
292-
293-
if (PyDict_GetItemStringRef(d, "minimum", &tmp) < 0) {
294-
return -1;
295-
}
296-
UFUNC_MINIMUM = (PyUFuncObject *)tmp;
297-
298285
/*
299286
* Set up promoters for logical functions
300287
* TODO: This should probably be done at a better place, or even in the

0 commit comments

Comments
 (0)