11#include <Python.h>
22
33#define PY_ARRAY_UNIQUE_SYMBOL metadatadtype_ARRAY_API
4- #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
4+ #define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
5+ #define NPY_TARGET_VERSION NPY_2_0_API_VERSION
56#define NO_IMPORT_ARRAY
6- #include "numpy/arrayobject.h"
7- #include "numpy/experimental_dtype_api.h"
87#include "numpy/ndarraytypes.h"
8+ #include "numpy/arrayobject.h"
99#include "numpy/ufuncobject.h"
10+ #include "numpy/dtype_api.h"
1011
1112#include "dtype.h"
1213#include "umath.h"
1314
1415static int
1516translate_given_descrs (int nin , int nout ,
16- PyArray_DTypeMeta * NPY_UNUSED (wrapped_dtypes []),
17- PyArray_Descr * given_descrs [],
17+ PyArray_DTypeMeta * const NPY_UNUSED (wrapped_dtypes []),
18+ PyArray_Descr * const given_descrs [],
1819 PyArray_Descr * new_descrs [])
1920{
2021 for (int i = 0 ; i < nin + nout ; i ++ ) {
@@ -35,8 +36,8 @@ translate_given_descrs(int nin, int nout,
3536
3637static int
3738translate_loop_descrs (int nin , int NPY_UNUSED (nout ),
38- PyArray_DTypeMeta * NPY_UNUSED (new_dtypes []),
39- PyArray_Descr * given_descrs [],
39+ PyArray_DTypeMeta * const NPY_UNUSED (new_dtypes []),
40+ PyArray_Descr * const given_descrs [],
4041 PyArray_Descr * original_descrs [],
4142 PyArray_Descr * loop_descrs [])
4243{
@@ -102,9 +103,11 @@ add_wrapping_loop(const char *ufunc_name, PyArray_DTypeMeta **dtypes,
102103 return res ;
103104}
104105
105- int
106- init_ufuncs (void )
106+ PyObject *
107+ init_ufuncs (PyObject * module )
107108{
109+ import_umath ();
110+
108111 PyArray_DTypeMeta * binary_orig_dtypes [3 ] = {& MetadataDType , & MetadataDType ,
109112 & MetadataDType };
110113 PyArray_DTypeMeta * binary_wrapped_dtypes [3 ] = {
@@ -123,7 +126,9 @@ init_ufuncs(void)
123126 goto error ;
124127 }
125128
126- return 0 ;
129+ return module ;
127130error :
128- return -1 ;
131+
132+ Py_DECREF (module );
133+ return NULL ;
129134}
0 commit comments